felixakiragreen / react-kronos

A fast, intuitive, and elegant date and time picker for React.
https://felixakiragreen.github.io/react-kronos/
MIT License
90 stars 28 forks source link

Date Changes With Month Buttons #65

Open Wartybliggens opened 6 years ago

Wartybliggens commented 6 years ago

Hello and thanks for kronos! I have one big issue: when using the arrow buttons to change the calendar month, the date in the input changes. This is unexpected behavior. I would expect the date to only change when I select a specific day from the calendar (by clicking on it). The month buttons should only be for navigating. And besides that, it shouldn't be possible to change the date in the input to a date that's out of range, but that's what happens: I am (correctly) prevented from clicking on out-of-range days, but by advancing the month out of range the input date changes anyway. That should not be possible.

CarrierDirectMatt commented 6 years ago

please fix this :(

felixakiragreen commented 6 years ago

@Wartybliggens @CarrierDirectMatt Thanks for bringing this up, my apologies for not addressing it sooner.

The way I designed and implemented this component, this is expected behavior. Every time the user clicks on a button, it makes a change:

You do bring up a valid concern being, if the prop preventClickOnDateTimeOutsideRange is true, then the user should not be able to modify/advance the input to a date that is not allowed.

I will address this, I'm just not sure of the best way forward. My current line of thought is making it so that if preventClickOnDateTimeOutsideRange is true, then the arrows only navigate.

Wartybliggens commented 6 years ago

Thank you @dubert for looking at this. I still think it's strange that the navigation at the top of the dropdown would change the date, when I would expect it to get me to a place where I can choose the day. My suggestion would be to make this an explicit toggle, like "changeDateWithNavigation", defaulting to true for backwards-compatibility.