the controlled value is reset, the placeholder is displayed (everything ok on the outside)
open the datepicker again
the datepicker displays the value from the step 1, expected would be to see the defaultValue - a clear() method needs to be called.
Scenario - Focus the datepicker
My controlled form fields, have focus() method, where I can focus the field when its appropriate - e.g. error is detected while submitting the form.
Currently I cannot propagate my ref to the Datepicker. So the Datepicker should accept the ref, and delegate the focus call into the
internal inputRef as inputRef.current.focus() called in useImperativeHandle.
Additional
Possibly other methods, like blur() could be added, I don't have real use case for this right now so it's optional.
Summary
It should be possible to forward
ref
to the Datepicker, in order to focus its input, or clear the value.Currently the Datepicker is uncontrolled (only accepting
defaultValue
, notvalue
prop) https://github.com/themesberg/flowbite-react/issues/1039. Alternative to controlled component is programmatic API exposing methods to the ref object viauseImperativeHandle
.Context
Scenario - Clear Datepicker
I have a controlled Datepicker which a problematic scenario:
defaultValue
- aclear()
method needs to be called.Scenario - Focus the datepicker
My controlled form fields, have
focus()
method, where I can focus the field when its appropriate - e.g. error is detected while submitting the form.Currently I cannot propagate my
ref
to theDatepicker
. So the Datepicker should accept the ref, and delegate thefocus
call into the internalinputRef
asinputRef.current.focus()
called inuseImperativeHandle
.Additional
Possibly other methods, like
blur()
could be added, I don't have real use case for this right now so it's optional.