[Bug][TimePicker] onChange does not update the value in adaptive mode
I'm submitting a bug report.
Current behavior
The TimePicker component's onChange does not get the new value in its event when selecting a value from the Popup. This is only reproduced in adaptive mode. Therefore, if the component is handled in controlled mode, the selected value will not be set to the value property.
Expected behavior
The onChange always receives the newly selected value.
Minimal reproduction of the problem with instructions
- Open this demo https://stackblitz.com/edit/react-hb3jww-twk3va?file=app%2Fmain.jsx
- Decrease the screen width until it is less than
768px - Select a value from the Popup
- The value is not selected in the component and
e.value.targetis not equal to the selected value
Workaround
Handle the component in uncontrolled mode. If the value is needed after every change, it can be taken by passing a ref to the TimePicker component, and using it on the onChange event:
- https://stackblitz.com/edit/react-hb3jww?file=app%2Fmain.jsx
Another solution would be to handle the component in controlled mode, set a default value to the value state variable that is passed to the value prop, and set this state variable in the onChange event to either e.value, ref.current.state.candidate, or ref.current.state.value depending on which of them is not null:
- https://stackblitz.com/edit/react-hb3jww-mrnnph?file=app%2Fmain.jsx
Also reported is Ticket ID: 1642433
Reported in Ticket ID: 1655031