#DateInput - Prevent partial input from choosing assumed date

6 messages · Page 1 of 1 (latest)

amber vault
#

Our use case will be that we expect user to type in the date, and if they needed to check whether next monday was the 3rd or the 4th, they may pop up the picker.

The problem comes in when someone is midway through typing the date.. .the DateInput assumes stuff about the rest of the date, so if you type 2005 and were to hit tab, it sets the date to 2005-1-1.

Is there a way to just not auto select jan 1, and have an invalid date until the user clears, or provides a valid date?

Seems like this functionality makes sense for how the component works, but could easily lead to invalid date entries

candid cairn
#

I think what you want is to set the prop fixOnBlur={false}

amber vault
#

@candid cairn I can tell you right now, that if the initial state is null/undefined, we most definitely did not see it revert back to no value, it seemed like it'd choose 01 for day of month, jan for month, 2001 for year... if you didnt provide any part of that. It makes sense that internally the date input would need that to flip to the correct month/year for calendar view

#

Just tested and even if I set a valid date value, then clear the date and type jan and hit tab, it sets the date to jan 1, 2001 (even with fixOnBlur = false

candid cairn
#

You were getting that behavior because the DateInput is not fully cleared without the clearable prop. You could see that in the
Date: {dateValue?.toLocaleDateString()} <br />