Skip to content

Conversation

@Ashish2097
Copy link
Contributor

@Ashish2097 Ashish2097 commented Jan 25, 2022

Closes #30731

@mui-bot
Copy link

mui-bot commented Jan 25, 2022

Details of bundle changes

Generated by 🚫 dangerJS against 381d1c1

@danilo-leal danilo-leal added the scope: pickers Changes related to the date/time pickers. label Jan 25, 2022
@danilo-leal danilo-leal changed the title Fix/30731 mobile picker cancel [Pickers] Fix mobile picker cancel button Jan 25, 2022
Copy link
Member

@mnajdova mnajdova left a 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

@mnajdova mnajdova added the PR: needs test The pull request needs tests. label Jan 26, 2022
@Ashish2097
Copy link
Contributor Author

Hi @mnajdova, added the test cases.

@Ashish2097 Ashish2097 requested a review from mnajdova January 27, 2022 10:28
@hbjORbj hbjORbj added type: bug It doesn't behave as expected. and removed PR: needs test The pull request needs tests. labels Jan 28, 2022
@hbjORbj hbjORbj changed the title [Pickers] Fix mobile picker cancel button [Pickers] Fix cancel behaviour in MobileDatePicker Jan 28, 2022
@hbjORbj hbjORbj requested a review from siriwatknp February 2, 2022 10:42
@hbjORbj hbjORbj changed the title [Pickers] Fix cancel behaviour in MobileDatePicker [Pickers] Fix onDismiss handler in MobileDatePicker Feb 2, 2022
@hbjORbj hbjORbj force-pushed the fix/30731-mobile-picker-cancel branch from 989f4d4 to 381d1c1 Compare February 2, 2022 11:44
@hbjORbj
Copy link
Contributor

hbjORbj commented Feb 2, 2022

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

Comment on lines +73 to +74
const [initialDate, setInitialDate] = React.useState<TDateValue>(draftState.committed);

Copy link
Member

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)

Copy link
Contributor

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).

Copy link
Member

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 👍

Copy link
Member

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 :)

Copy link
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.

👍 This is awesome for the first contribution!

@hbjORbj hbjORbj merged commit 6eb0003 into mui:master Feb 3, 2022
@mnajdova
Copy link
Member

mnajdova commented Feb 3, 2022

@flaviendelangle FYI

@flaviendelangle
Copy link
Member

Thanks, I'm reproducing it on MUI-X 👍

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

Labels

scope: pickers Changes related to the date/time pickers. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MobileDatePicker's Cancel button does not work.

8 participants