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
[fields] Fix field editing after closing the picker #12675
[fields] Fix field editing after closing the picker #12675
Conversation
Deploy preview: https://deploy-preview-12675--material-ui-x.netlify.app/ |
@LukasTy the e2e tests are broken 👍 |
@flaviendelangle This is a totally random problem that made no sense to me... 🙈 🤷 |
😭 |
onOpen: () => void; | ||
onClose: () => void; | ||
onOpen: (event: React.UIEvent) => void; | ||
onClose: (event?: React.UIEvent) => void; |
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.
Do we have places where we pass the event to onClose
?
This PR only passes them to onOpen
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.
Explicitly nope, but implicitly it is called by clicking on the open picker button and this is basically the reason why our selection indexes get screwed up... 🙈
Without this, the fix doesn't work as the input selection logic gets called.
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.
OK make sense 👍
Fixes #12652.
Clicking the open button causes the following event to be triggered and if default is not prevented, it executes the input DOM selection logic.
mui-x/packages/x-date-pickers/src/internals/hooks/useField/useFieldV6TextField.ts
Lines 248 to 257 in f617d70
Changed the
onOpen
andonClose
actions to callevent.preventDefault()
to avoid such problems.