Skip to content

Commit

Permalink
fix: 🐛 date picker PaginationMini select (#2587)
Browse files Browse the repository at this point in the history
Co-authored-by: JOJO <1>
  • Loading branch information
Ricinix authored Nov 15, 2023
1 parent f8160e0 commit 08bc0ae
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
46 changes: 24 additions & 22 deletions src/date-picker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,28 +109,30 @@ const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>((originalProps, r
}
}
// 头部快速切换
const onJumperClick = React.useCallback(({ trigger }) => {
const monthCountMap = { date: 1, week: 1, month: 12, quarter: 12, year: 120 };
const monthCount = monthCountMap[mode] || 0;

const current = new Date(year, month);

let next = null;
if (trigger === 'prev') {
next = subtractMonth(current, monthCount);
} else if (trigger === 'current') {
next = new Date();
} else if (trigger === 'next') {
next = addMonth(current, monthCount);
}

const nextYear = next.getFullYear();
const nextMonth = next.getMonth();

setYear(nextYear);
setMonth(nextMonth);
// eslint-disable-next-line
}, []);
const onJumperClick = React.useCallback(
({ trigger }) => {
const monthCountMap = { date: 1, week: 1, month: 12, quarter: 12, year: 120 };
const monthCount = monthCountMap[mode] || 0;

const current = new Date(year, month);

let next = null;
if (trigger === 'prev') {
next = subtractMonth(current, monthCount);
} else if (trigger === 'current') {
next = new Date();
} else if (trigger === 'next') {
next = addMonth(current, monthCount);
}

const nextYear = next.getFullYear();
const nextMonth = next.getMonth();

setYear(nextYear);
setMonth(nextMonth);
},
[year, month, mode, setYear, setMonth],
);

// timePicker 点击
function onTimePickerChange(val: string) {
Expand Down
3 changes: 1 addition & 2 deletions src/date-picker/panel/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ export default function PanelContent(props: PanelContentProps) {
({ trigger }) => {
onJumperClick?.({ trigger, partial });
},
// eslint-disable-next-line
[partial],
[partial, onJumperClick],
);

return (
Expand Down

0 comments on commit 08bc0ae

Please sign in to comment.