Skip to content

Commit

Permalink
fix(range): panel keep open when nextValue is empty(ant-design#26024) (
Browse files Browse the repository at this point in the history
…ant-design#122)

* fix(range): panel keep open when nextValue is empty(ant-design#26024)

* chore: udpate test case
  • Loading branch information
kerm1it committed Aug 10, 2020
1 parent bb155c6 commit 8edfbe3
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/RangePicker.tsx
Expand Up @@ -470,7 +470,7 @@ function InnerRangePicker<DateType>(props: RangePickerProps<DateType>) {
if (
nextOpenIndex !== null &&
nextOpenIndex !== mergedActivePickerIndex &&
!openRecordsRef.current[nextOpenIndex] &&
(!openRecordsRef.current[nextOpenIndex] || !getValue(values, nextOpenIndex)) &&
getValue(values, sourceIndex)
) {
// Delay to focus to avoid input blur trigger expired selectedValues
Expand Down
36 changes: 36 additions & 0 deletions tests/range.spec.tsx
Expand Up @@ -1696,4 +1696,40 @@ describe('Picker.Range', () => {
).toEqual('2020-07-24 06:00:00');
expect(wrapper.find('.rc-picker-ok button').props().disabled).toBeTruthy();
});

// https://github.com/ant-design/ant-design/issues/26024
it('panel should keep open when nextValue is empty', () => {
const wrapper = mount(<MomentRangePicker />);

wrapper.openPicker(0);

wrapper.selectCell(7, 0);
expect(
wrapper
.find('input')
.first()
.prop('value'),
).toBe('1990-09-07');

// back to first panel and clear input value
wrapper
.find('input')
.first()
.simulate('focus');
wrapper.inputValue('', 0);

// reselect date
wrapper.selectCell(9, 0);
expect(
wrapper
.find('input')
.first()
.prop('value'),
).toBe('1990-09-09');

// end date
wrapper.selectCell(9, 1);

matchValues(wrapper, '1990-09-09', '1990-10-09');
});
});

0 comments on commit 8edfbe3

Please sign in to comment.