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] Date picker bug with disablePast #12373

Closed
stephenwade opened this issue Mar 7, 2024 · 4 comments · Fixed by #12377
Closed

[pickers] Date picker bug with disablePast #12373

stephenwade opened this issue Mar 7, 2024 · 4 comments · Fixed by #12377
Assignees
Labels
bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module!

Comments

@stephenwade
Copy link

stephenwade commented Mar 7, 2024

Steps to reproduce

Link to live example: https://codesandbox.io/p/sandbox/twilight-paper-kgh5c9

  1. Add the disablePast attribute to the date picker.
  2. Set the date to next year, but less than 1 year from now (for example: March 6, 2025).
  3. Set the year back to the current year.

Current behavior

The typical behavior is to keep the time component the same. After following the above steps, the time component will be reset to 00:00:00.

Expected behavior

The time component should not change.

Context

The date picker is modifying a date with a time component of 23:59:59. In most cases, the result after the date picker still has a time of 23:59:59, but in this case the time is reset to 00:00:00.

Your environment

npx @mui/envinfo

I used Google Chrome.

  System:
    OS: macOS 14.3.1
  Binaries:
    Node: 18.19.1 - /opt/homebrew/bin/node
    npm: 10.2.4 - /opt/homebrew/bin/npm
    pnpm: 8.15.3 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 122.0.6261.112
    Edge: Not Found
    Safari: 17.3.1

Search keywords: date picker disablePast

@stephenwade stephenwade added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Mar 7, 2024
@flaviendelangle
Copy link
Member

Hi,
Thanks for your contribution

This dateOnly does not exist on our component, where did you see it?

@flaviendelangle flaviendelangle added status: waiting for author Issue with insufficient information component: pickers This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Mar 8, 2024
@LukasTy LukasTy added the bug 🐛 Something doesn't work label Mar 8, 2024
@LukasTy LukasTy self-assigned this Mar 8, 2024
@LukasTy LukasTy removed the status: waiting for author Issue with insufficient information label Mar 8, 2024
@LukasTy LukasTy changed the title Date picker bug with dateOnly and disablePast [pickers] Date picker bug with dateOnly and disablePast Mar 8, 2024
@LukasTy
Copy link
Member

LukasTy commented Mar 8, 2024

Confirming that this is a problem with the pickers behavior.
If there is already a present date, we shouldn't reset it, but use its time when changing the day.

@stephenwade stephenwade changed the title [pickers] Date picker bug with dateOnly and disablePast [pickers] Date picker bug with disablePast Mar 8, 2024
@stephenwade
Copy link
Author

I apologize for the confusion, dateOnly was a prop in our internal date picker component to choose between DesktopDatePicker and DesktopDateTimePicker. I've removed the references in the title and demo.

Copy link

⚠️ This issue has been closed.
If you have a similar problem, please open a new issue and provide details about your specific problem.
If you can provide additional information related to this topic that could help future readers, please feel free to leave a comment.

How did we do @stephenwade?
Your experience with our support team matters to us. If you have a moment, please share your thoughts through our brief survey.

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

3 participants