[Datepicker] [Timepicker] Can't override placeholder text due to input format
See original GitHub issue- The issue is present in the latest release.
- I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Passing placeholder to renderInput does not do anything due to input format.
Expected Behavior 🤔
Placeholder on renderInput should be passed to input, rather than input format if placeholder is passed.
Steps to Reproduce 🕹
<TimePicker
renderInput={props => (
<TextField
{...props}
helperText="override works today"
placeholder="override does nothing"
/>
)}
label={'Label'}
// This is forced placeholder text
inputFormat={'h:mm a'}
/>
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
[Datepicker] [Timepicker] Can't override placeholder text due ...
This appears to be the correct way of doing it. Date/time pickers put the placeholder directly into inputProps - attributes applied to the...
Read more >How to set the placeholder text of the MUI DatePicker?
The reason it doesn't work is because it is overridden by the params.inputProps provided by the DatePicker itself based on the inputFormat :...
Read more >How to set placeholder value for input type date in HTML 5
The placeholder attribute does not work with the input type Date, so place any value as a placeholder in the input type Date....
Read more >DatePicker - Ant Design
To select or input a date. ... Time. Switchable picker. Switch in different types of pickers by Select. ... We can set the...
Read more >Form Datepicker | Components - BootstrapVue
BootstrapVue custom date picker input form control, which provides full WAI-ARIA ... Add custom placeholder text to the control, when no date is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sherlock2017
This appears to be the correct way of doing it. Date/time pickers put the
placeholder
directly intoinputProps
- attributes applied to the input element (not to be confused withInputProps
, which areInput
component props), so we have to override that.Posting for clarification since the approach is somewhat counter-intuitive, and the first post example is misleading.
<LocalizationProvider dateAdapter={AdapterDateFns} style={{ width: "40px" }} > <TimePicker value={time} onChange={setTime} renderInput={(params) => ( <TextField placeholder="Add Class Time" {...params} style={{ width: "198px" }} /> )} /> </LocalizationProvider>
Still, this isn’t working, can anyone help!