Skip to content

Commit

Permalink
fix(date-picker): over parse when valueType is Date (#3127)
Browse files Browse the repository at this point in the history
* fix(date-picker): over parse when valueType is Date

* chore: fix lint
  • Loading branch information
uyarn committed Apr 11, 2024
1 parent 97202b6 commit 1aa39e2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/date-picker/DatePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineComponent, watch, computed } from 'vue';
import dayjs from 'dayjs';
import { CalendarIcon as TdCalendarIcon } from 'tdesign-icons-vue';
import isDate from 'lodash/isDate';

import { usePrefixClass } from '../hooks/useConfig';
import { useGlobalIcon } from '../hooks/useGlobalIcon';
Expand Down Expand Up @@ -51,7 +52,10 @@ export default defineComponent({
const isDisabled = computed(() => formDisabled.value || props.disabled);

watch(popupVisible, (visible) => {
const dateValue = value.value ? covertToDate(value.value as string, formatRef.value?.valueType) : value.value;
// Date valueType add empty string don't need to be parsed
const dateValue = value.value && !isDate(value.value)
? covertToDate(value.value as string, formatRef.value?.valueType)
: value.value;

cacheValue.value = formatDate(dateValue, {
format: formatRef.value.format,
Expand Down

0 comments on commit 1aa39e2

Please sign in to comment.