Skip to content

Commit

Permalink
chore: fix mode change
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Dec 7, 2023
1 parent 77bd724 commit edbdba1
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/NewPicker/PickerInput/SinglePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -309,19 +309,13 @@ function Picker<DateType extends object = any>(
// >>> Mode need wait for `pickerValue`
const triggerModeChange = useEvent(
(nextPickerValue: DateType, nextMode: PanelMode, triggerEvent?: boolean) => {
const clone = fillIndex(modes, activeIndex, nextMode);

if (clone[0] !== modes[0] || clone[1] !== modes[1]) {
setMode(clone);
}
setMode(nextMode);

// Compatible with `onPanelChange`
if (onPanelChange && triggerEvent !== false) {
const clonePickerValue: DateType = [...calendarValue];
if (nextPickerValue) {
clonePickerValue[activeIndex] = nextPickerValue;
}
onPanelChange(clonePickerValue, clone);
const lastPickerValue: DateType =
nextPickerValue || calendarValue[calendarValue.length - 1];
onPanelChange(lastPickerValue, nextMode);
}
},
);
Expand Down

0 comments on commit edbdba1

Please sign in to comment.