diff --git a/src/RangePicker.tsx b/src/RangePicker.tsx index be155abaf..01abf0ce9 100644 --- a/src/RangePicker.tsx +++ b/src/RangePicker.tsx @@ -632,7 +632,7 @@ function InnerRangePicker(props: RangePickerProps) { onSubmit: () => { if ( // When user typing disabledDate with keyboard and enter, this value will be empty - !selectedValue || + !selectedValue?.[index] || // Normal disabled check (disabledDate && disabledDate(selectedValue[index])) ) { diff --git a/tests/keyboard.spec.tsx b/tests/keyboard.spec.tsx index cb79e65e6..88db3f244 100644 --- a/tests/keyboard.spec.tsx +++ b/tests/keyboard.spec.tsx @@ -586,4 +586,25 @@ describe('Picker.Keyboard', () => { expect(isSame(onSelect.mock.calls[0][0], '1990-12-03')).toBeTruthy(); }); }); + + it('range picker value should be empty array when typing invalid or disabledDate to start date', () => { + const onCalendarChange = jest.fn(); + const now = new Date(); + const { container } = render( + date.month() < now.getMonth()} + />, + ); + + openPicker(container); + fireEvent.change(container.querySelector('input'), { target: { value: '1990-1-1' } }); + closePicker(container); + expect(onCalendarChange.mock.calls).toEqual([]); + + openPicker(container); + fireEvent.change(container.querySelector('input'), { target: { value: '2000-01-01' } }); + closePicker(container); + expect(onCalendarChange.mock.calls).toEqual([]); + }); });