Skip to content

Commit 424e96a

Browse files
kerm1itafc163
authored andcommitted
fix(range): panel keep open when nextValue is empty(#26024) (#122)
* fix(range): panel keep open when nextValue is empty(#26024) * chore: udpate test case
1 parent cf792bd commit 424e96a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/RangePicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ function InnerRangePicker<DateType>(props: RangePickerProps<DateType>) {
470470
if (
471471
nextOpenIndex !== null &&
472472
nextOpenIndex !== mergedActivePickerIndex &&
473-
!openRecordsRef.current[nextOpenIndex] &&
473+
(!openRecordsRef.current[nextOpenIndex] || !getValue(values, nextOpenIndex)) &&
474474
getValue(values, sourceIndex)
475475
) {
476476
// Delay to focus to avoid input blur trigger expired selectedValues

tests/range.spec.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,4 +1696,40 @@ describe('Picker.Range', () => {
16961696
).toEqual('2020-07-24 06:00:00');
16971697
expect(wrapper.find('.rc-picker-ok button').props().disabled).toBeTruthy();
16981698
});
1699+
1700+
// https://github.com/ant-design/ant-design/issues/26024
1701+
it('panel should keep open when nextValue is empty', () => {
1702+
const wrapper = mount(<MomentRangePicker />);
1703+
1704+
wrapper.openPicker(0);
1705+
1706+
wrapper.selectCell(7, 0);
1707+
expect(
1708+
wrapper
1709+
.find('input')
1710+
.first()
1711+
.prop('value'),
1712+
).toBe('1990-09-07');
1713+
1714+
// back to first panel and clear input value
1715+
wrapper
1716+
.find('input')
1717+
.first()
1718+
.simulate('focus');
1719+
wrapper.inputValue('', 0);
1720+
1721+
// reselect date
1722+
wrapper.selectCell(9, 0);
1723+
expect(
1724+
wrapper
1725+
.find('input')
1726+
.first()
1727+
.prop('value'),
1728+
).toBe('1990-09-09');
1729+
1730+
// end date
1731+
wrapper.selectCell(9, 1);
1732+
1733+
matchValues(wrapper, '1990-09-09', '1990-10-09');
1734+
});
16991735
});

0 commit comments

Comments
 (0)