-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[Pickers] Fix onDismiss handler in MobileDatePicker
#30768
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
[Pickers] Fix onDismiss handler in MobileDatePicker
#30768
Conversation
mnajdova
left a comment
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.
Let's add test for it
|
Hi @mnajdova, added the test cases. |
packages/mui-lab/src/MobileDatePicker/MobileDatePicker.test.tsx
Outdated
Show resolved
Hide resolved
MobileDatePicker
MobileDatePickeronDismiss handler in MobileDatePicker
Co-authored-by: Benny Joo <[email protected]>
989f4d4 to
381d1c1
Compare
|
I can confirm in this codesandbox that the issue is fixed. Codesandbox before the fix: https://codesandbox.io/s/eloquent-feather-iznb0?file=/src/Demo.tsx |
| const [initialDate, setInitialDate] = React.useState<TDateValue>(draftState.committed); | ||
|
|
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.
This means initialDate will always be the first value of draftState.committed. Is this the expected behavior? (I don't know the whole implementation but creating another state kinda concern me a bit because it can create another bug where the state is not updated)
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.
It is set to the value of draftState.committed when the component first loads, and afterwards, it is newly set every time user clicks "OK". (We call setInitialDate inside acceptDate function, only if needClosePicker is true. You can check my last commit).
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 see, thanks for the explanation 👍
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.
Yeah, we need one more additional state :)
siriwatknp
left a comment
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.
👍 This is awesome for the first contribution!
|
@flaviendelangle FYI |
|
Thanks, I'm reproducing it on MUI-X 👍 |
Closes #30731