RangePicker: A month is added to the end date when it is on the same month as the start date
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Steps to reproduce
- Open RangePicker
- Highlight date text input at the top of the popup and enter any date (eg. 2019-03-12)
- Navigate with tab to the second field
- Enter end date that’s on the same month as start date (eg. 2019-03-25)
- Close picker by pressing Enter
What is expected?
The date range should be 2019-03-12 to 2019-03-25
What is actually happening?
A month is added to the end date, so the resulting range is 2019-03-12 to 2019-04-25. The day of the month changes correctly, the month number is invalid.
Environment | Info |
---|---|
antd | 3.15.0 |
React | 16.8.4 |
System | Linux, but irrelevant |
Browser | irrelevant, tested on Chromium 72 and FF 65 |
I couldn’t pinpoint the line that causes the issue – it can be very well because of some flawed logic in underlying rc-calendar/RangeCalendar
. The cause seems to be one too many end.clone().add(1, 'month')
, like there is in the getShowDateFromValue.
Also since choosing the date with mouse on a single picker pane works correctly, I suspect it has to do with combining the dates from 2 different CalendarPart
components.
More information:
If you disable date range in the reproduction to disallow picking 2019-04-25, you will not be able to close the picker and select date by pressing Enter when in the second input. You can however input the date, navigate back to the first text input and then close it.
// try setting the range to 2019-03-07 to 2019-03-12 and closing the picker with Enter
<DatePicker.RangePicker
defaultValue={[moment().subtract(5, "day"), moment(5, "day").subtract(5, "day")]}
disabledDate={currentDate => currentDate.isAfter(moment())}
/>
If you close the popup by clicking outside of it with mouse, the end date is correctly set, as if it was not validated (?) and modified.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:7 (1 by maintainers)
Any update on this?
Any update on this? Still experiencing a month getting added to the end date. Would appreciate a simple fix