Skip to content

Conversation

@oliviertassinari
Copy link
Member

@oliviertassinari oliviertassinari commented Aug 24, 2025

For as long as I can remember, I have seen people leave duplicate feedback. This has been more frequent lately. https://mui-org.slack.com/archives/C0757QYLK7V/p1756026303219189 was the trigger for me to finally spend some time looking at it (I have deleted the duplicate in Slack). I hope it solves the problem, a quick win.

Here is a reproduction:

Screen.Recording.2025-08-24.at.22.54.25.mov

@oliviertassinari oliviertassinari added type: bug It doesn't behave as expected. docs Improvements or additions to the documentation. scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). labels Aug 24, 2025
@mui-bot
Copy link

mui-bot commented Aug 24, 2025

Netlify deploy preview

https://deploy-preview-46824--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 596752d

const handleSubmitComment = (event) => {
event.preventDefault();
// Block more than one submission.
if (commentOpen !== true) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just

Suggested change
if (commentOpen !== true) {
if (!commentOpen) {

?

I believe technically there's a race condition here, if someone clicks fast enough to have the second click come in before the next render 😬. Probably will never happen in practice though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just

Fair enough. If this file was in TypeScript, I would have done this. Updated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe technically there's a race condition here, if someone clicks fast enough to have the second click come in before the next render 😬. Probably will never happen in practice though.

Agree, we would need to use a ref to be 100% certain but it feels overkill. I'm leaving it as a comment, in case for the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it was more of an observation. I was just wondering what would be a great pattern. Do set state callbacks have to be pure? I suppose otherwise one could do

setOpen(isOpen => {
  if (isOpen) sendFeedback()
  return false
})

but I can't say this excites me in any way. better leave it as is.

Co-authored-by: Jan Potoms <2109932+Janpot@users.noreply.github.com>
Signed-off-by: Olivier Tassinari <oliviertassinari@users.noreply.github.com>
Signed-off-by: Olivier Tassinari <oliviertassinari@users.noreply.github.com>
@oliviertassinari oliviertassinari merged commit 3634b32 into mui:master Aug 25, 2025
21 checks passed
@oliviertassinari oliviertassinari deleted the fix-feedback-double-submissions branch August 25, 2025 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to the documentation. scope: docs-infra Involves the docs-infra product (https://www.notion.so/mui-org/b9f676062eb94747b6768209f7751305). type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants