mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[pickers] It is no longer possible to override the placeholder value

Open JcPires opened this issue 10 months ago โ€ข 9 comments

Steps to reproduce

V7.0.0

Link to live example:

https://github.com/mui/mui-x/assets/15987808/de31e161-d5b8-415e-b0f3-6d6a1a5e0e28

Steps:

  1. Add a value for the placeholder in the slotProps object and the field key
  2. The placeholder is not defined

This behavior worked in the previous version v6.19.8

Current behavior

If the developer enters a value for the placeholder is not correctly replaced in the final rendering

Expected behavior

If the developer enters a value for the placeholder it's correctly replaced in the final rendering

Context

No response

Your environment

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

Search keywords: DatePicker

JcPires avatar Mar 26 '24 18:03 JcPires

@JcPires I can confirm that this is a regression to v6. I will add this to our board for the team to have a look! Thanks for raising this! ๐Ÿ™‡๐Ÿผ

michelengelen avatar Mar 27 '24 16:03 michelengelen

@michelengelen Is there an ETA on when this might get fixed? It is breaking our tests which were relying on this feature

heath-freenome avatar Mar 28 '24 01:03 heath-freenome

@heath-freenome It will at worse be released in one week :+1: There is a chance to add it to this week release, but I can't guarantee anything since it's already release day.

flaviendelangle avatar Mar 28 '24 09:03 flaviendelangle

@JcPires, @heath-freenome do note that the field slot technically doesn't have such property. Please use the slotProps.textField.placeholder instead, especially if you are in a TS environment.

LukasTy avatar Mar 28 '24 10:03 LukasTy

:warning: 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 @JcPires? Your experience with our support team matters to us. If you have a moment, please share your thoughts through our brief survey.

github-actions[bot] avatar Mar 28 '24 10:03 github-actions[bot]

If I understand correctly, overriding the placeholders in x-date-pickers v7 will only work with MUI v6? Can something be done to make it work with MUI v5? I want to use DateTimeRangePicker with MUI v5.

oskarkk avatar May 10 '24 22:05 oskarkk

If I understand correctly, overriding the placeholders in x-date-pickers v7 will only work with MUI v6? Can something be done to make it work with MUI v5? I want to use DateTimeRangePicker with MUI v5.

@oskarkk could you clarify your question? Are you asking if @mui/x-date-pickers v7 will only work with @mui/material v6? If that's the question, then definitely no, we have an explicit peer dependency on a minimum required @mui/material v5 version. ๐Ÿ˜‰ https://github.com/mui/mui-x/blob/eb2654717136245e5db0983bd49343d4e58c8443/packages/x-date-pickers/package.json#L60

LukasTy avatar May 13 '24 07:05 LukasTy

@LukasTy I had a problem with placeholders not working with MUI v5.15.14, but it has magically started working, both in my code where I had the problem and in codesandbox, so I don't know. (In the tests added in the PR I saw "v6 only" so I was assuming that maybe I shouldn't use it with MUI v5.)

But there's still a smaller issue with placeholders in pickers v7: undefined or empty string doesn't remove placeholder, it still leaves the default "hh:mm" etc.

Here it's working with pickers v6: https://codesandbox.io/p/sandbox/clf85l

Not working with pickers v7: https://codesandbox.io/p/sandbox/mui-time-picker-placeholder-overrride-forked-zsyj9q

I can make a new issue with this if you want.

oskarkk avatar May 13 '24 09:05 oskarkk

Here it's working with pickers v6: https://codesandbox.io/p/sandbox/clf85l

Not working with pickers v7: https://codesandbox.io/p/sandbox/mui-time-picker-placeholder-overrride-forked-zsyj9q

I can make a new issue with this if you want.

@oskarkk could you clarify what is not working specifically? From your demos, I'd say that the @mui/x-date-pickers v6 demo has an "issue" of using the placeholder value of undefined, which is technically the same as not defined and "using" it to show no placeholder, whereas a correct approach of doing that would be an empty string "". But, I can confirmโ€”it does not seem to work as the existing solution doesn't account for the empty string case. ๐Ÿ™ˆ

I'm opening this issue as it's directly related to it and the applied fix, thank you. ๐Ÿ™

LukasTy avatar May 13 '24 12:05 LukasTy

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

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

github-actions[bot] avatar May 16 '24 09:05 github-actions[bot]

Thanks for the fast reaction and fix!

oskarkk avatar May 16 '24 11:05 oskarkk