-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[docs] Create a recipe of a read-only textfield field #12342
Comments
I just added the Order ID above |
Hello @zgheibali, As for the P.S. If you are binding value like this in your application, please consider changing it to avoid unnecessary re-renders. Currently, whenever your root component would re-run - it would force a re-render of |
Hello Lukas, Thank you for getting back! Here's a sandbox where I reproduced the issue: https://codesandbox.io/p/sandbox/dry-https-737fgn To clarify my issue: when the user clicks on the input field, the format "MM/DD/YYYY" shows up instead of an empty string (or "Start Date" placeholder) and when the user selects his date.. this format disappears. What is expected: I want to hide the format "MM/DD/YYYY" completely, and based on the comments that I read in the issue section, I believe the "placeholder" param is expected to do that, no? I tried it and it's not working for some reason. I also don't want to go with a custom text field from scratch as I would lose all the functionality in this case. any suggestion? |
Hi, Our field component allow editing through the keyboard arrows and single section selection like the browser built-in component. If you render an empty input when focusing, then you can't navigate between the sections when the value is empty or press "ArrowDown" / "ArrowUp" etc... to change its value. That's why @LukasTy proposed to render a custom field, that would indeed not have our editing behavior but would fit this requirement. |
@LukasTy I'm wondering if a good recipe on how to build a custom field with a mask approach (like on v5) would make sense. WDYT? |
@flaviendelangle much appreciated for the feedback So in case I got this correctly, the current date format is injected as the value to the input field to support the feature of changing the input via UP/DOWN/RIGHT/LEFT keys, right? Now if I pass the placeholder it won't work due to the support of the feature above, right? Regarding the custom field approach: do you have any working custom field code sample for the date range picker that I can start with and build on that? That would be GREAT! Thanks again! |
I completely agree, this is probably at least the 3rd time we are getting this question. 🙈
Yes, take a look at how the native date input behaves. The field component introduced in v6 closely resembles that behavior.
Yes, that behavior depends on changing the value in the input, so, if you would check the DOM, when the input is focused, what you are actually calling a
I'm not aware of such an example. We'd need to build it. |
The closest we got is this example where we replace the input with an Autocomplete. But adding a masked-based example would but a good way to cover all the custom input-based examples because people could see which props to forward to the input. |
I worked on this a bit, and here's what I came up with: https://codesandbox.io/p/sandbox/dry-https-737fgn Do you think all is good? or am I missing something? any feedback is appreciated Also, I'm not exactly sure about the "masked" feature that you are talking about. I would just like a date range picker with toolbars that popups when the user clicks on the input. is the "masked" feature something that I might have to worry about? |
@zgheibali That is a bit "hacky", but a working solution. 👌 |
I've moved the issue to grooming in order to discuss the best approach and what actual changes do we need on our end. 😉 |
We will firstly solve #13515, which will solve the pain points for introducing a completely custom behavior for |
This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue. Note @zgheibali 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. |
Steps to reproduce
Im trying to hide the placeholder when the user clicks on the date range picker input
I'm trying:
however, for some reason this doesn't work. any suggestion?
Current behavior
In case I add an empty placeholder (or an actual value), the placeholder flickers/changes quickly to the new value and then displays back the date format (e.g. DD/MMM/YYYY)
Expected behavior
I would like to hide the date format (e.g. DD/MMM/YYYY or whatever) from the placeholder and show an empty input if possible
Context
No response
Your environment
npx @mui/envinfo
Search keywords: DateRangePicker
Order ID: 69994
The text was updated successfully, but these errors were encountered: