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.12k stars 1.28k forks source link

[fields] "Format" is still being used as MobileDatePicker input value, even after the dialog is closed #13679

Closed ignatiusreza closed 2 months ago

ignatiusreza commented 3 months ago

Steps to reproduce

Link to live example: https://codesandbox.io/s/sad-firefly-c5ptqr?file=/src/Demo.js

Steps:

  1. Click to open date picker dialog
  2. Select on today's date
  3. Click OK --> noticed that date picker value is updated correctly
  4. Click a 2nd time to open date picker dialog
  5. Click on "Clear" --> noticed that date picker value is mistakenly set to the string given as "format"

Current behavior

Date picker input "value" is set to "format".

Expected behavior

Date picker input "value" should be "null" (blank)

Alternatively, for MobileDatePicker (and MobileDateTimePicker), it might not be necessary for placeholder to be assigned as value when the input is focused. Since the expectation is for the user to pick the date (& time) via the date picker dialog.

Context

We customized the default date picker actionbar, to enable user to "Clear" current value of the datepicker.

Your environment

npx @mui/envinfo Reproducible in code sandbox, browser: Chrome.

Search keywords: datepicker format placeholder

LukasTy commented 3 months ago

@ignatiusreza Thank you for opening this issue. The behavior indeed looks strange. The different behavior of the readOnly flag, which is set on Mobile Pickers, causes this issue.

We'll look into this issue. 👍

github-actions[bot] commented 2 months ago

:warning: This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@ignatiusreza: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.