osuresearch / ui

Ohio State Research UI
https://osuresearch.github.io/ui/main
MIT License
6 stars 3 forks source link

Fix: changed `DateField` exposed typing information from `DateValue` to `string` (resolves 66) #71

Closed helloLilyX closed 1 year ago

helloLilyX commented 1 year ago
helloLilyX commented 1 year ago

Typo in my second commit message. Cleaned up DateField not LookupField

helloLilyX commented 1 year ago

Observation:

Shouldn't the value attribute in the hidden <input> element have undefined and trigger an error for DateField 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 its undefined or null value to its default value?

helloLilyX commented 1 year ago

Confusion in my version:

helloLilyX commented 1 year ago

Also there's a type error in form.stories.tsx: Screenshot 2023-04-21 at 4 58 30 PM

Ignore this, I saw it was recently fixed in version 5.0.0-alpha.18