Skip to content

Commit

Permalink
fix(date-range-picker): fix panel interaction error
Browse files Browse the repository at this point in the history
  • Loading branch information
gavin-hao authored and jack0pan committed May 10, 2022
1 parent 70c42f0 commit dcfa107
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/static-date-picker/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const DatePicker: React.FC<StaticDatePickerProps> = ({
}) => {
const locale = useLocale<Locale>('DatePicker') || defaultLocale;

const [viewDate, setViewDate] = useState(() => viewDateProp ?? value ?? defaultValue ?? new Date());
const [viewDate, setViewDate] = useControlledState(viewDateProp, value ?? defaultValue ?? new Date());
const [innerValue] = useControlledState(value, defaultValue);
const [mode] = useState<PickerMode>('date');
const currentPickerMode = useRef(mode);
Expand Down Expand Up @@ -77,12 +77,12 @@ const DatePicker: React.FC<StaticDatePickerProps> = ({
{...restProps}
pickerValue={viewDate}
onSelect={(date) => { onSelect?.(date); }}
onChange={(date) => { setViewDate(date) }}
onChange={(date) => { setViewDate(date, true) }}
locale={locale}
prefixCls={prefixCls}
onPanelChange={(changedValue, changedMode: PickerMode) => {
currentPickerMode.current = changedMode;
setViewDate(changedValue);
setViewDate(changedValue, true);
onPanelChange?.(changedValue, changedMode);
}}
picker={mode}
Expand Down

0 comments on commit dcfa107

Please sign in to comment.