mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.07k stars 1.26k forks source link

[pickers][DatePicker] Incorrect display of value in input field when Controlled component #14519

Closed mseweryn45 closed 1 week ago

mseweryn45 commented 1 week ago

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:

michelengelen commented 1 week ago

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. 👍🏼

LukasTy commented 1 week ago

Thank you for opening this issue and providing a great reproduction example. 🙏 This looks like a duplicate of https://github.com/mui/mui-x/issues/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. 😉