Skip to content

[menu][select] Prevent activation during exit transition#48347

Open
mj12albert wants to merge 1 commit into
mui:masterfrom
mj12albert:fix-menu-item-activating-during-exit-transition
Open

[menu][select] Prevent activation during exit transition#48347
mj12albert wants to merge 1 commit into
mui:masterfrom
mj12albert:fix-menu-item-activating-during-exit-transition

Conversation

@mj12albert
Copy link
Copy Markdown
Member

Set set pointer-events: none when closed so they can't be accidentally activated during the exit transition

Fixes #27992

@mj12albert mj12albert added type: bug It doesn't behave as expected. scope: menu Changes related to the menu. scope: select Changes related to the select. labels Apr 21, 2026
@mj12albert mj12albert changed the title [menu item] Prevent activation during exit transition [menu][select] Prevent activation during exit transition Apr 21, 2026
@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented Apr 21, 2026

Deploy preview

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

Bundle size

Bundle Parsed size Gzip size
@mui/material 🔺+57B(+0.01%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/private-theming 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


Check out the code infra dashboard for more information about this PR.

@mj12albert mj12albert force-pushed the fix-menu-item-activating-during-exit-transition branch from 7097d74 to a8bfd43 Compare April 21, 2026 15:59
@mj12albert mj12albert marked this pull request as ready for review April 21, 2026 16:34
@mj12albert mj12albert force-pushed the fix-menu-item-activating-during-exit-transition branch 2 times, most recently from 7e91fc0 to e774355 Compare April 27, 2026 09:43
Copy link
Copy Markdown
Member

@siriwatknp siriwatknp left a comment

Choose a reason for hiding this comment

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

I want to be very careful on fixes like this.
To me, the issue is a very edge case without upvotes.

Introducing the pointer events none could introduce a different bug that we could not know on the user land.

In my opinion, we could:

  • provide the workaround via theming, exactly like the fix you propose and close the issue as not planned
  • wait for @silviuaavram opinion

@mj12albert
Copy link
Copy Markdown
Member Author

To me, the issue is a very edge case without upvotes.

This was also my first impression of the issue, but it's very easily reproducible by a fast/accidental/sloppy click

Autocomplete already added this:

// Prevent interaction with stale cached options during exit transitions.
// The hook's filteredOptions is [] when popupOpen=false, so clicks on stale
// rendered options would pass undefined to selectNewValue.
pointerEvents: popupOpen ? undefined : 'none',

IMO this is a safe change because it's guarded by the popup's open state, so it should have no effect when the popup and options can actually be interacted with

@mj12albert mj12albert force-pushed the fix-menu-item-activating-during-exit-transition branch from e774355 to 5896c2d Compare May 4, 2026 11:44
@silviuaavram
Copy link
Copy Markdown
Member

I agree this is really edge case. Looking at the autocomplete change, it's not clear to me if it's for the same thing. The issues linked in the PR seem different, unless I'm mistaken.

@mj12albert
Copy link
Copy Markdown
Member Author

mj12albert commented May 5, 2026

Looking at the autocomplete change, it's not clear to me if it's for the same thing

The fix in #48327 for #36304 applies CSS pointer-events: none to the options when the open state is false (popup is closed)

The issue with autocomplete is similar but broader than menu/select – autocomplete options incorrectly unmounted before the exit transition finishes, so the fix there persisted them until the transition finished (doesn't happen here); and then same as this PR, added CSS pointer-events: none based on popupOpen: false (it's false when transitioning out) so you can't click them and change the value again when the popup is supposed to be closing @silviuaavram

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: menu Changes related to the menu. scope: select Changes related to the select. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[menu][select] Items can still be activated during exit transition

3 participants