-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Autocomplete] Fix listbox opened unexpectedly when component is disabled
#38611
[Autocomplete] Fix listbox opened unexpectedly when component is disabled
#38611
Conversation
Netlify deploy previewhttps://deploy-preview-38611--material-ui.netlify.app/ Bundle size reportDetails of bundle changes (Toolpad) |
e90da58
to
9932304
Compare
Manually tested a prior issue affecting the pickers: https://codesandbox.io/s/pickers-hidden-label-click-test-9q8k4m?file=/demo.tsx |
5e1dff6
to
3d0a55d
Compare
3d0a55d
to
617d8f2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this looks very simple :)
I couldn't find anything wrong with it.
It looks nice 👍 |
Fixes #36867
Here is a sandbox with the original repro and a simplified one that shows the fix: https://codesandbox.io/s/https-github-com-mui-material-ui-pull-38611-3hygqs?file=/demo.tsx
I can hardly believe how simple this fix could be, but it make sense to block the popup from opening if the component is
disabled
:Here is the simplified repro (I colored different parts of it) showing the bug: https://codesandbox.io/s/https-github-com-mui-material-ui-issues-36867-m25xds?file=/demo.tsx
Both cases are reproducible:
input
slot or thepopupIndicator
- it will open the popup.Seems that when the click handler on the
InputBase
fires (it will even though the Autocomplete is disabled, reason here), it will trigger thehandleInputMouseDown
(here), and open the popup.popupIndicator
(green or blue area), move the cursor until it is over the popup indicator (red area) then release the mouse button - it will open the popup.Not 100% sure what's going on but since fixing case 1 automatically fixed this one, I guess it's still triggering the click handler of
InputBase
even though the cursor is no longer directly over it, and thedisabled
popup button doesn't block the mouseup/click phase of the user action 🤔