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] Incorrect display of value in input field when Controlled component #14519

Closed
mseweryn45 opened this issue Sep 6, 2024 · 2 comments
Labels
bug 🐛 Something doesn't work component: date picker This is the name of the generic UI component, not the React module! component: pickers This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists

Comments

@mseweryn45
Copy link

mseweryn45 commented Sep 6, 2024

Steps to reproduce

Link to live example: https://stackblitz.com/edit/react-4eslb9?file=Demo.tsx

Steps:

  1. Choose any date
  2. Again select any other day from the same month again
DatePickerValue-demo-.-MUI-X---StackBlitz.webm

Current behavior

After first select input displays the first day of the selected month, but after second select the selected one is displayed, even though the one of the first day of the month is passed in the variable

Expected behavior

DatePicker after the change will take the value that was passed using the variable

Context

When creating a component with a lock on the need to select the date of the first day of the month, there is an inconsistency between the displayed date and the one we have stored

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: datepicker value controlled

Search keywords:

@mseweryn45 mseweryn45 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Sep 6, 2024
@zannager zannager transferred this issue from mui/material-ui Sep 6, 2024
@zannager zannager added the component: pickers This is the name of the generic UI component, not the React module! label Sep 6, 2024
@michelengelen michelengelen changed the title [DatePicker] Incorrect display of value in input field when Controlled component [pickers][DatePicker] Incorrect display of value in input field when Controlled component Sep 6, 2024
@michelengelen
Copy link
Member

This is happening because every time (after the first correct behavior) the value and newValue are exactly equal. I do agree that we should not change the input value internally in that case. This seems like a bug, so I'll add it to the board. 👍🏼

@michelengelen michelengelen added bug 🐛 Something doesn't work component: date picker 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 Sep 6, 2024
@LukasTy
Copy link
Member

LukasTy commented Sep 9, 2024

Thank you for opening this issue and providing a great reproduction example. 🙏
This looks like a duplicate of #10424.
I'm closing this issue as a duplicate.
If you think that my assumption is incorrect, feel free to comment or reopen the issue. 😉

@LukasTy LukasTy closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
@LukasTy LukasTy added the duplicate This issue or pull request already exists label Sep 9, 2024
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: date picker This is the name of the generic UI component, not the React module! component: pickers This is the name of the generic UI component, not the React module! duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants