-
-
Notifications
You must be signed in to change notification settings - Fork 761
Description
There is a From and To DayPickerInput element on a page. Both have a value that comes from state.
When the From field is changed, an onDayChange function is used to update the value of the From and To dates in state.
However...
if the new From date is in a different month, then on the very first change of the From date the To date will not be updated.
There appears to be an issue in the DayPickerInput.js, componentWillReceiveProps function whereby this condition (if (hasDifferentValue && !shouldDisplayAnotherMonth)) is causing an issue. Based on my test scenario, hasDifferentValue is true, and shouldDisplayAnotherMonth is also true, and therefore there is no mapping of the nextProps to state - i.e. the state is not updated with the changed date.
Issue has been reproduced at:
https://codesandbox.io/s/yjo1nzx51z
Use the following steps to reproduce:
Scenario 1
- From and To dates default to 30-Oct-2017
- Change the From date to 15-Nov-17. Note the To date does not change. Expectation is this would have been updated to 15-Nov-17.
- Change the From date to 16-Nov-17. Note the To date does change. As expected.
Scenario 2 (NOTE: refresh the browser to start again):
- From and To dates default to 30-Oct-2017
- Change the From date to 31-Oct-2017. Note the To date does change. As expected.
Scenario 3 (NOTE: refresh the browser to start again):
- From and To dates default to 30-Oct-2017
- Click on the To date to note that the calendar is displayed in October.
- Change the From date to 15-Sep-2017. Note the To date does not change. Expectation is this would have been updated to 15-Sep-2017.
- Click on the To date to note that the calendar is displayed in September.
- Change the From date to 16-Sep-2017. Note the To date does change. As expected.