-
-
Notifications
You must be signed in to change notification settings - Fork 734
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
Can't set empty value for input ( reproduction ) #804
Comments
Ran into this issue as well. Looks like PR #816 should fix this assuming it gets merged. |
This would be a temporary solution. I have solved it this way, it is not recommended to use refs but ... xD <DayPickerInput
value={from}
ref={(el) => (this.from = el)}
.../>
<DayPickerInput
value={to}
ref={(el) => (this.to = el)}
.../>
handleResetClick = () => {
// this fixed the encapsulated input uncontrolled bug
this.from.setState({ value: '', typedValue: '' });
this.to.setState({ value: '', typedValue: '' });
}; I hope this works for people who still fail. |
In order to avoid refs, I used another little hack 😅
|
This has been fixed in the latest releases - please upgrade thanks |
Though I've upgraded to 7.4.8 I don't see this being resolved. When I clear out the value (in a blur function when the entry is deemed to be invalid) the typedValue remains the same. Is there something more that needs to be done besides simply upgrading to 7.4.8? |
The latest release still exhibits this problem when clearing a value that is not a valid Date. I've played around changing the following line to also set the typed value to the given value & the problem seems to go away. https://github.com/gpbl/react-day-picker/blob/v7/src/DayPickerInput.js#L198
However I'm not a 100% certain this is the best solution, but it seems to work for my use case, where dates are stored in the form state as plain strings. |
There was a similar error, but could not reproduce it.
https://codesandbox.io/s/7m6q1y8xmj
reproduction
The text was updated successfully, but these errors were encountered: