Skip to content

Commit

Permalink
chore: comment it
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Dec 4, 2023
1 parent ace680e commit 83e5533
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/examples/debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ export default () => {
// }
// return false;
// }}
minDate={dayjs().add(-1, 'day')}
maxDate={dayjs().add(2, 'month')}
minDate={dayjs().add(-12, 'month')}
maxDate={dayjs().add(-6, 'month')}
placeholder={['Start', 'End']}
suffixIcon="🧶"
onFocus={(_, info) => {
Expand Down
1 change: 1 addition & 0 deletions src/NewPicker/PickerInput/hooks/useRangePickerValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export default function useRangePickerValue<DateType extends object = any>(
}
}, [open, mergedActiveIndex]);

// >>> Reset prevActiveIndex when panel closed
React.useEffect(() => {
if (open) {
prevActiveIndexRef.current = mergedActiveIndex;
Expand Down
18 changes: 18 additions & 0 deletions tests/new-range.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1128,4 +1128,22 @@ describe('NewPicker.Range', () => {
expect(onChange).not.toHaveBeenCalled();
});
});

it('minDate and maxDate', () => {
const { container } = render(
<DayRangePicker minDate={dayjs()} maxDate={dayjs().add(1, 'month')} />,
);

openPicker(container);

expect(document.querySelectorAll('.rc-picker-header-super-prev-btn')[0]).toHaveStyle({
visibility: 'hidden',
});
expect(document.querySelectorAll('.rc-picker-header-super-next-btn')[1]).toHaveStyle({
visibility: 'hidden',
});

expect(findCell(2)).toHaveClass('rc-picker-cell-disabled');
expect(findCell(31, 1)).toHaveClass('rc-picker-cell-disabled');
});
});

0 comments on commit 83e5533

Please sign in to comment.