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

[TimePicker] How to set minutes current date after select hour #10316

Open
Kwunnnnn opened this issue Sep 12, 2023 · 7 comments
Open

[TimePicker] How to set minutes current date after select hour #10316

Kwunnnnn opened this issue Sep 12, 2023 · 7 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature

Comments

@Kwunnnnn
Copy link

TimePicker suggests minutes to '00' after selecting the hour row but '00' has disabled minutes. I want to not set default minutes at '00' I want the current minute. How can I do it?

Example: https://codesandbox.io/s/mui-x-issue-ls7npj

Expect: I want to select the hour as '19' and minutes auto-select at '30'

@github-actions github-actions bot added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 12, 2023
@flaviendelangle
Copy link
Member

Hi,

You can use the referenceDate prop to change the default minutes (see this example)

But the default behavior should probably be smarter (cc @LukasTy)

@flaviendelangle flaviendelangle added component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Sep 12, 2023
@Kwunnnnn
Copy link
Author

Thank you, It's work 🚀🚀🚀

@flaviendelangle
Copy link
Member

I'll keep the issue open to track the progress of the built-in support (if we want to improve it)

@Kwunnnnn
Copy link
Author

I have one more question. If I want to reset row minute after select new hour value, How can I do?

@flaviendelangle
Copy link
Member

You could probably analyse the value passed to onChange and when the hour changes between the old and the new value, you reset the minutes.
But there is no specific API to help you do that 👍

@LukasTy
Copy link
Member

LukasTy commented Sep 12, 2023

But the default behavior should probably be smarter

Good point. We could add a similar improvement as we have with the DateCalendar, where it will look for the closest non-disabled date when navigating the calendar.

@flaviendelangle
Copy link
Member

That would be a great improvement 👌

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! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

No branches or pull requests

3 participants