Closed helloLilyX closed 1 year ago
Typo in my second commit message. Cleaned up DateField
not LookupField
Observation:
DateField
has a defaultValue = "08-14-1989"
. The value
attribute in its hidden <input>
element changed accordingly as we expected when I put in a valid date. However, when I deleted the entire date part (DatedField
showed as 8/dd/1989
), the value
attribute in the hidden <input>
element changed to "08-14-1989"
(which is the default value). Then I clicked on the "Submit" button, FieldValue
had "dateField: null"
.Shouldn't the
value
attribute in the hidden<input>
element haveundefined
and trigger an error forDateField
in RHF?
I currently have <input aria-hidden="true" name={props.name} type="text" value={state.value?.toString()} />
which should set the value
attribute in the hidden <input>
element to undefined
when state.value
is undefined
(state.value
works fine), however, it showed as `"08-14-1989".
For the RHF part, I have onChange: (value: DateValue | undefined) => onChange && onChange(value?.toString())
sets "DateField": undefined
correctly (It's not printed out under FieldValue
because {formData ? JSON.stringify(formData, undefined, 2) : 'Submit the form to view FieldValues'}
is used to show formData
, but undefined
doesn't exist in JSON(null
does)).
My guess: does
<input>
have a setting that would convert itsundefined
ornull
value to its default value?
Confusion in my version:
value
had undefined
. However, no matter what the time part was before, it became "14" (DateField
showed as 8/14/1989
). I console.log
ed state
, and state.value
had the DateValue
version of 8/14/1989
. If I deleted three more times on the date part, it would eventually have 8/dd/1989
.Also there's a type error in
form.stories.tsx
:
Ignore this, I saw it was recently fixed in version 5.0.0-alpha.18