Skip to content
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][DatePicker] Allow same date to be selected with onChange event fired #12903

Open
AgrYpn1a opened this issue Apr 25, 2024 · 5 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it

Comments

@AgrYpn1a
Copy link

AgrYpn1a commented Apr 25, 2024

Summary

I am using a StaticDatePIcker in a custom dropdown menu which needs to be closed after the day has been selected. I am using onChange to detect that selection, however, if I press on the same day (which is still a valid use case, because I want to confirm that I want to use the already selected day) the onChange is not triggered.

I saw that there used to be a prop called allowSameDateSelection that allows for that behaviour but for some reason it is removed. Is there any other way to achieve this without customising the days renderer or similar?

Examples

No response

Motivation

No response

Search keywords: static date picker

@AgrYpn1a AgrYpn1a added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 25, 2024
@zannager zannager added the component: pickers This is the name of the generic UI component, not the React module! label Apr 25, 2024
@michelengelen michelengelen changed the title Allow same date to be selected with onChange event fired [pickers] Allow same date to be selected with onChange event fired Apr 26, 2024
@michelengelen
Copy link
Member

Well, technically this is correct behaviour, since the value does not change.
@LukasTy can we provide a different "point of entry" for this? Maybe with slotProps.day.onDaySelect?

@michelengelen michelengelen added the status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it label Apr 26, 2024
@AgrYpn1a
Copy link
Author

@michelengelen Thanks for the fast response, indeed it is, but I still need a way to detect that user has clicked on that day in the calendar.

@michelengelen
Copy link
Member

That's where @LukasTy could be of help. 👍🏼

@codemasterblackperl
Copy link

codemasterblackperl commented May 1, 2024

@michelengelen as @AgrYpn1a mentioned, in v5 pickers we can detect same-day selection. We built our scheduling system based on this behavior. Same-day selection provided the toggling functionality. The toggling functionality broke when we tried to update the x-date pickers to v6 because it is no longer firing the selected day if you click on it again.

It would be great to have this function back

@michelengelen
Copy link
Member

michelengelen commented May 2, 2024

OK, I will add this to the board. 👍🏼

I do not think that we might want to fire an onChange as technically the value did not change, but we are likely to find another solution for this.

@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 2, 2024
@michelengelen michelengelen changed the title [pickers] Allow same date to be selected with onChange event fired [pickers][DatePicker] Allow same date to be selected with onChange event fired May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! status: expected behavior Does not imply the behavior is intended. Just that we know about it and can't work around it
Projects
None yet
Development

No branches or pull requests

4 participants