t1m0n / air-datepicker

Lightweight, dependency-free JavaScript datepicker.
https://air-datepicker.com
MIT License
2.62k stars 1.37k forks source link

prevent datepicker from closing when range=true and only one date was selected #588

Closed elYanuki closed 7 months ago

elYanuki commented 7 months ago

When using a range input it was possible for the user to only select one date and then exit the picker by clicking outside it. This created a case where only a single date was selected with the second still being undefined. Neither toggleSelected nor specifying pre selected dates would fix this.

You might want to put this behind another option like forceRangeSelection but i dont see why anyone would want the behaviour mentioned above.

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
air-datepicker ❌ Failed (Inspect) Feb 20, 2024 6:11pm
elYanuki commented 7 months ago

i now realized this is not the optimal approach, its probably smarter to just no accept the selection and revert to the original date instead of forcing the picker to stay open. this is nicer for ux reasons since an accidental click doesnt matter and for ui reasons since u cant run into random open popups covering stuff or multiple existing.

i will change my code and resubmit a pr