react-tailwindcss-datepicker icon indicating copy to clipboard operation
react-tailwindcss-datepicker copied to clipboard

DatePicker won't reset on reset button press within an html form

Open mmcossu opened this issue 1 year ago • 2 comments

put the DatePicker in a form with a reset button and assign an inputName:

export function PickerExample() {
  return (
    <form>
      <DatePicker inputName={'_in'} value={null} onChange={_ => {}}/>
      <button type=reset">Reset</button>
    </form>
  )
}

Select a date, then press the reset button... Normally a reset event should trigger a form elements collection to adopt the reset mechanism, by emptying themselves. Although the DatePicker component includes a element, this won't be cleared.

It should either expose a .Reset() function to be invoked via the useRef() hook, or it should be fixed to use the form events as intended.

mmcossu avatar Mar 27 '24 17:03 mmcossu

I have faced similar issue. I have fixed it by adding Key in the DatePicker component

AmitJain628 avatar Aug 08 '24 09:08 AmitJain628

AmitJain628 what value to the key? any value that can differ in time? like a Date.now() to force a re render of the component on reset?

mmcossu avatar Oct 31 '24 09:10 mmcossu