Skip to content

Commit

Permalink
fix(datepicker): fix datepicker week parse error (#2841)
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn authored Apr 11, 2024
1 parent 7e7acd4 commit bd91ba6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/date-picker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { forwardRef, useEffect, useCallback } from 'react';
import classNames from 'classnames';
import dayjs from 'dayjs';
import isDate from 'lodash/isDate';
import useConfig from '../hooks/useConfig';
import { StyledProps } from '../common';
import { TdDatePickerProps, PresetDate } from './type';
Expand Down Expand Up @@ -64,7 +65,11 @@ const DatePicker = forwardRef<HTMLDivElement, DatePickerProps>((originalProps, r

useEffect(() => {
// 面板展开重置数据
const dateValue = value ? covertToDate(value as string, valueType) : value;
// Date valueType、week mode 、quarter mode nad empty string don't need to be parsed
const dateValue =
value && !isDate(value) && !['week', 'quarter'].includes(props.mode)
? covertToDate(value as string, valueType)
: value;
setCacheValue(formatDate(dateValue, { format }));
setInputValue(formatDate(dateValue, { format }));

Expand Down

0 comments on commit bd91ba6

Please sign in to comment.