Skip to content

Commit 8ffbe9b

Browse files
authored
fix: Picker maxDate limit (#761)
1 parent f04eeb9 commit 8ffbe9b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/PickerInput/hooks/useRangePickerValue.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ export default function useRangePickerValue<DateType extends object, ValueType e
204204
? offsetPanelDate(generateConfig, pickerMode, nextPickerValue, 1)
205205
: nextPickerValue;
206206
if (maxDate && generateConfig.isAfter(offsetPickerValue, maxDate)) {
207-
nextPickerValue = offsetPanelDate(generateConfig, pickerMode, maxDate, -1);
207+
nextPickerValue = multiplePanel
208+
? offsetPanelDate(generateConfig, pickerMode, maxDate, -1)
209+
: maxDate;
208210
}
209211

210212
setCurrentPickerValue(nextPickerValue, 'reset');

tests/picker.spec.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,4 +1434,11 @@ describe('Picker.Basic', () => {
14341434
testPropsName('defaultValue');
14351435
testPropsName('defaultOpenValue');
14361436
});
1437+
1438+
it('auto switch pickerValue - maxDate', () => {
1439+
const { container } = render(<DayPicker maxDate={dayjs('1989-01-01')} />);
1440+
1441+
openPicker(container);
1442+
expect(document.querySelector('.rc-picker-header-view').textContent).toBe('Jan1989');
1443+
});
14371444
});

0 commit comments

Comments
 (0)