You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using the most recent version of this package and I am writing a wrapper component to manage it and conform to some specifications. We are implementing a minimal HH:mm version of this component without the clock or any clear button functionality. One of the requirements is to make the component look like an actual input, and for the input to show a red border when in an invalid state.
This has proven to be quite difficult to manage given the behavior of the TimePicker. Firstly, the component appears to have been designed to be controlled if any custom formats are desired. This isn't a problem in and of itself, just mentioning it because I am now managing a state variable for the value. The second (and main) problem is that the TimePicker will automatically reset to its last known valid state without notifying its parent.
For example, if I am managing my own isValid state and initially render with a default value with required as false, there's no problem (note that my wrapper component is providing the feeling of being uncontrolled, hence the label):
isValid===truevalue==='00:00'
Then, I clear the hours field, causing an invalid state:
onInvalidChange()// the TimePicker fires this and my component re-rendersisValid===falsevalue==='00:00'
Then I tab to the (valid) minutes field, then out of it (to some other element):
// no callback fires (e.g. `onChange`) and therefore no component re-renderisValid===falsevalue==='00:00'
As you can see, no accessible callback fires that notifies my component that the TimePicker has reset the inputs to a valid state, so my component can't update any state and re-render in order remove the red border. I understand that onChange is already firing for valid states, but it would be really helpful if there was a way to notify the parent component that the component resets to a valid state in this situation. Unfortunately, I have to resort to document.querySelectorAll in order to get element references, along with an effect in order to manually attach event listeners (e.g. blur/keyup to each input and evaluate their values/validity, which is too complex for my tastes.
Any assistance you could provide here would be great!
The text was updated successfully, but these errors were encountered:
I am using the most recent version of this package and I am writing a wrapper component to manage it and conform to some specifications. We are implementing a minimal
HH:mm
version of this component without the clock or any clear button functionality. One of the requirements is to make the component look like an actual input, and for the input to show a red border when in an invalid state.This has proven to be quite difficult to manage given the behavior of the
TimePicker
. Firstly, the component appears to have been designed to be controlled if any custom formats are desired. This isn't a problem in and of itself, just mentioning it because I am now managing a state variable for the value. The second (and main) problem is that theTimePicker
will automatically reset to its last known valid state without notifying its parent.For example, if I am managing my own
isValid
state and initially render with a default value withrequired
asfalse
, there's no problem (note that my wrapper component is providing the feeling of being uncontrolled, hence the label):Then, I clear the hours field, causing an invalid state:
Then I tab to the (valid) minutes field, then out of it (to some other element):
As you can see, no accessible callback fires that notifies my component that the
TimePicker
has reset the inputs to a valid state, so my component can't update any state and re-render in order remove the red border. I understand thatonChange
is already firing for valid states, but it would be really helpful if there was a way to notify the parent component that the component resets to a valid state in this situation. Unfortunately, I have to resort todocument.querySelectorAll
in order to get element references, along with an effect in order to manually attach event listeners (e.g.blur
/keyup
to each input and evaluate their values/validity, which is too complex for my tastes.Any assistance you could provide here would be great!
The text was updated successfully, but these errors were encountered: