kendo-react icon indicating copy to clipboard operation
kendo-react copied to clipboard

[Bug][TimePicker] onChange does not update the value in adaptive mode

Open WissamProgress opened this issue 2 years ago • 1 comments

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

  1. Open this demo https://stackblitz.com/edit/react-hb3jww-twk3va?file=app%2Fmain.jsx
  2. Decrease the screen width until it is less than 768px
  3. Select a value from the Popup
  4. The value is not selected in the component and e.value.target is 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

WissamProgress avatar Nov 08 '23 13:11 WissamProgress

Also reported is Ticket ID: 1642433

WissamProgress avatar Feb 23 '24 12:02 WissamProgress

Reported in Ticket ID: 1655031

WissamProgress avatar Jun 12 '24 12:06 WissamProgress