react-dates: SingleDatePicker: No way to distinguish between invalid date and empty input
SingleDatePicker’s onDateChange handler is fired with null when user’s input doesn’t validate to a date. This can happen when the date is, in fact, invalid 13/13/2018 or when user input is empty.
Is there a way to tell these scenarios apart?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 46
- Comments: 16 (1 by maintainers)
We probably should make
onDateChangefired with either aDateobject or a string (contains whatever user’s original input) to fix this issue+1 this is driving me insane:)
Its probably a bug though, as onDateChanged should not be triggered at all. See README:
This is also tripping me up a little. My scenario is that I want to send a request to the server if the user “clears” the input, but I have no way of knowing if the
nulldate arg was because of an actual clearing of the input or a temporary edit that put the input into an invalid state.Perhaps additional arguments could be passed to the change handler, in addition to the date value? Something that refers to the validity of the current state of the input?
+1
@viktoriyavulfson Did you ever find a solution to this issue?
Hi I checked the actual value of the input. I am not quite sure if I used document.getElementById or a ref to get the input