shahabyazdi / react-multi-date-picker

a simple React datepicker component for working with gregorian, persian, arabic and indian calendars
https://shahabyazdi.github.io/react-multi-date-picker/
MIT License
766 stars 90 forks source link

TimePicker clear input field #261

Open huzeifajaha opened 6 months ago

huzeifajaha commented 6 months ago

using TimePicker of react multi date picker isuue is on clearing an input field of it my state get cleared on reset but input field show the time which i selected

const [value, setValue] = useState();

<DatePicker arrowClassName="arrowClass" containerClassName="containerClassTimePicker" value={value} disableDayPicker format="hh:mm A" calendar={calendarValue} locale={localValue} editable={false} plugins={[]} onChange={(value) => setValue(value) } /> <button onClick={() => setValue(null)}>reset how can i do this

Rezaraki commented 6 months ago

strange if you click anywhere outside the input and the button and then click on reset button it will be deleted from the input and nothing will be shown inside the input; but if after clicking inside the input you click on the button and not the problem you said happens. it seems that disabling the dayPicker by using disableDayPicker opens the calendar anyway but just doesn't show it and if you del the value before closing the calendar (by clicking outside of it) it glitches and never removes the value from the input.( unless you click on the input again and click outside of the input and then click on the reset)


one hacky way that comes to my mind for fixing it is using a 0 timeout to postpone the value change on button click to after the calendar close: ` <button onClick={() => { setTimeout(() => { setValue(null); }, 0); }}

reset `

ZahraMoosavi77 commented 1 month ago

unfortunately It does not work for me. Any solution please?

shahabyazdi commented 3 weeks ago

It should be fixed in v4.5.2

ZahraMoosavi77 commented 3 weeks ago

Yes, thanks 🙏

On Sat, Jun 15, 2024 at 11:29 Shahab @.***> wrote:

It should be fixed in v4.5.2

— Reply to this email directly, view it on GitHub https://github.com/shahabyazdi/react-multi-date-picker/issues/261#issuecomment-2169193389, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVMSFSZ4HFY4MD2EP7ICC3DZHPX6XAVCNFSM6AAAAABASSHFNOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNRZGE4TGMZYHE . You are receiving this because you commented.Message ID: @.***>