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

[DateTimePicker] disablePast is not disabling or validating time #4868

Closed
2 tasks done
karinehaug opened this issue Mar 17, 2021 · 3 comments · Fixed by #6226
Closed
2 tasks done

[DateTimePicker] disablePast is not disabling or validating time #4868

karinehaug opened this issue Mar 17, 2021 · 3 comments · Fixed by #6226
Assignees
Labels
bug 🐛 Something doesn't work component: DateTimePicker The React component. component: pickers This is the name of the generic UI component, not the React module!

Comments

@karinehaug
Copy link

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

When adding disablePast to DateTimePicker, previous dates are disabled and validations kicks in when typing past date. But the time picker are not disabling past time, and there is no validation to it either.

Expected Behavior 🤔

If current date is selected, past time should also be disabled in picker, and validation/onError should happen when typing past time.

Steps to Reproduce 🕹

https://codesandbox.io/s/datetimepicker-disablepast-qr8re?file=/src/App.tsx

Steps:

  1. The first DateTimePicker in the sandbox is displaying the expected validation error on past date
  2. The second DateTimePicker is not displaying the expected validation error on past time (except for when visiting the sandbox < 5 minutes past midnight 😅)

Context 🔦

I want to validate that the datetime is not in the past and is not before some other date (so I've already used the minDateTime for that)

Your Environment 🌎

`npx @material-ui/envinfo`
  Don't forget to mention which browser you used.
  Output from `npx @material-ui/envinfo` goes here.
@karinehaug karinehaug added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 17, 2021
@oliviertassinari oliviertassinari added the component: DateTimePicker The React component. label Mar 28, 2021
@mnajdova
Copy link
Member

This is not supported currently. Even the description of the props disablePast and disableFuture states that they are disabling future/past days

image

I'd say this is low priority, but we could wait for upvotes. What do you think @eps1lon ?

@mnajdova mnajdova removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 19, 2021
@oliviertassinari oliviertassinari changed the title disablePast is not disabling or validating time for DateTimePicker [DateTimePicker] disablePast is not disabling or validating time Apr 19, 2021
@oliviertassinari oliviertassinari added the bug 🐛 Something doesn't work label Apr 19, 2021
@eps1lon
Copy link
Member

eps1lon commented Apr 20, 2021

disablePast should consider its context. For example, in a DatePicker it should only error if it is given a past day. But in a DateTimePicker it should also error if the hour is in the past.

Right now disablePast only considers days which is confusing. I think it's reasonable to expect that <DateTimePicker disablePast /> considers time and not just date.

The immediate solution is to rename disablePast to disablePastDays but I think long term we do want to error if the time in a DateTimePicker is in the past and disablePast is true.

@flaviendelangle flaviendelangle transferred this issue from mui/material-ui May 13, 2022
@flaviendelangle flaviendelangle added the component: pickers This is the name of the generic UI component, not the React module! label May 13, 2022
@flaviendelangle
Copy link
Member

I will take care of this issue after #4814 👍

@flaviendelangle flaviendelangle self-assigned this May 13, 2022
@flaviendelangle flaviendelangle removed their assignment Sep 7, 2022
@flaviendelangle flaviendelangle changed the title [DateTimePicker] disablePast is not disabling or validating time [DateTimePicker] disablePast is not disabling or validating time Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: DateTimePicker The React component. component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants