-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
[CalendarPicker] Prevent getting focus when autoFocus=false
#6304
Conversation
These are the results for the performance tests:
|
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.
Nice fix
I did not test it, but what is preventing us from doing this update in the render like we do in usePickerState
?
React tends to recommend that approach over an effect: https://fr.reactjs.org/docs/hooks-faq.html#how-do-i-implement-getderivedstatefromprops
@flaviendelangle I don't get to which part of |
mui-x/packages/x-date-pickers/src/internals/hooks/usePickerState.ts Lines 257 to 260 in 85dadfa
|
20ce901
to
5b1a229
Compare
It's not possible because it updates multiple components, and apparently, you should not update your parents during the render phase. Only inside effect. I assume the proposed technic to derive state from props only works if the state is limited to the current component |
Make sense 👍 |
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 to merge it as is 👍
In DatePicker doc page the focus is caught by the year picker.
This PR should fix this bug