From 04a7c698ffd62347e46791637dab114b2d7eafe1 Mon Sep 17 00:00:00 2001 From: sallerli1 Date: Wed, 29 Jun 2022 15:06:15 +0800 Subject: [PATCH] feat: temp --- .../date-picker/src/composables/useActiveValue.ts | 2 +- .../src/composables/useRangePanelState.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/components/date-picker/src/composables/useActiveValue.ts b/packages/components/date-picker/src/composables/useActiveValue.ts index 5b370a8f4..a4444aa2a 100644 --- a/packages/components/date-picker/src/composables/useActiveValue.ts +++ b/packages/components/date-picker/src/composables/useActiveValue.ts @@ -125,7 +125,7 @@ export function useRangeActiveValue( setActiveValue([fromValue, calcValidActiveDate(fromValue, toValue, 'to')]) } - const [activeValue, setActiveValue] = useControlledProp(props, 'activeValue', () => [ + const [activeValue, setActiveValue] = useControlledProp(props, 'activeValue', [ fromPanelValue.value ?? now, calcValidActiveDate(fromPanelValue.value ?? now, toPanelValue.value, 'to'), ]) diff --git a/packages/components/date-picker/src/composables/useRangePanelState.ts b/packages/components/date-picker/src/composables/useRangePanelState.ts index a10c7d606..8da801fe5 100644 --- a/packages/components/date-picker/src/composables/useRangePanelState.ts +++ b/packages/components/date-picker/src/composables/useRangePanelState.ts @@ -5,10 +5,10 @@ * found in the LICENSE file at https://github.com/IDuxFE/idux/blob/main/LICENSE */ -import type { DateRangePickerPanelProps } from '../types' +import type { DateRangePanelProps } from '../types' import type { DateConfig } from '@idux/components/config' -import { type ComputedRef, computed } from 'vue' +import { type ComputedRef, computed, watch } from 'vue' import { callEmit, convertArray, useState } from '@idux/cdk/utils' @@ -22,9 +22,15 @@ export interface RangePanelStateContext { handleDatePanelCellMouseenter: (value: Date) => void } -export function useRangePanelState(props: DateRangePickerPanelProps, dateConfig: DateConfig): RangePanelStateContext { +export function useRangePanelState(props: DateRangePanelProps, dateConfig: DateConfig): RangePanelStateContext { const [selectingDate, setSelectingDate] = useState<(Date | undefined)[] | undefined>(props.value) const [isSelecting, setIsSelecting] = useState(false) + watch( + () => props.visible, + () => { + setIsSelecting(false) + }, + ) const panelValue = computed(() => { if (isSelecting.value) {