customInput component with input child cannot be typed in
See original GitHub issueWhen creating a date picker with a custom input component, typing into the input field auto-formats to the incorrect date. For example, if the following date is in the input field: 01/01/2019, backspacing twice will automatically change the date to 01/01/2020. Backspacing 3 more times changes the date to 01/01/2002.
This is my code that is experiencing the issue:
const MyForm = () => (
<DateInput />
);
const DateInput = () => {
const [test, setTest] = useState(new Date());
return (
<DatePicker selected={test} onChange={date => setTest(date)} customInput={<CustomInput />
);
}
const CustomInput = ({value, onClick, onChange}) => (
<input value={value} onClick={onClick} onChange={onChange} />
);
Oddly enough, when using the standard date picker (without the custom input), everything works as expected.
Below is a gif of what happens when backspacing in the date picker with a custom input component
Issue Analytics
- State:
- Created 4 years ago
- Reactions:13
- Comments:7
Top Results From Across the Web
React-hook-form v7 - Custom input warning Function ...
React-hook-form v7 - Custom input warning Function components cannot be given refs ; name="host" ; label="Adresse host *" ; error={errors.host} ;..
Read more >Unable to type in input after adding value prop #8053 - GitHub
The problem was that i wrote a custom form component, which cloned all child inputs via mapChildren . However, the suggested defaultValue prop ......
Read more >Custom input components - Sanity.io
This article will explore the pieces and steps necessary to create a custom input component from scratch.
Read more >Creating a custom input component for Sanity Studio - YouTube
This video may contain code snippets or concepts that are specific to a previous version of Sanity Studio. In most cases, you can...
Read more >Vue custom input - DEV Community
Most of us have faced it: build a custom input component. ... The way Vue works is: the child component has props that...
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 Free
Top 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
Wow. When I tried this (onFocus) in custom input, the focus seemed to flicker back and forth from input to calendar at a crazy rate. Completely not working.
@antiold @benuleau you actually have to additionally pass down
onFocus
to the CustomInput to avoid this issue. The following code doesn’t reproduce the bug:This is not intuitive though, it ought to be somewhere in the documentation.
Using react-datepicker 2.10.1