From 26d5e0230d9b1b4eaa31dbe34c834cb99de3e7b0 Mon Sep 17 00:00:00 2001 From: "xiaziqi.sia" Date: Thu, 12 Dec 2024 16:12:51 +0800 Subject: [PATCH] fix: keep empty value in renderLinkedContainer of `DatePicker` --- packages/arcodesign/components/date-picker/index.tsx | 8 ++++++-- packages/arcodesign/components/date-picker/type.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/arcodesign/components/date-picker/index.tsx b/packages/arcodesign/components/date-picker/index.tsx index 9fc9398d..8d0bebb5 100644 --- a/packages/arcodesign/components/date-picker/index.tsx +++ b/packages/arcodesign/components/date-picker/index.tsx @@ -7,7 +7,7 @@ import React, { Ref, useImperativeHandle, } from 'react'; -import { cls, componentWrapper, formatDateNumber } from '@arco-design/mobile-utils'; +import { cls, componentWrapper, formatDateNumber, isEmptyValue } from '@arco-design/mobile-utils'; import Picker, { PickerRef } from '../picker'; import { PickerData, ValueType } from '../picker-view'; import { ContextLayout } from '../context-provider'; @@ -292,7 +292,11 @@ const DatePicker = forwardRef((props: DatePickerProps, ref: Ref) touchToStop={touchToStop} renderLinkedContainer={ renderLinkedContainer - ? () => renderLinkedContainer(currentTs, keyOptions) + ? () => + renderLinkedContainer( + isEmptyValue(props.currentTs) ? undefined : currentTs, + keyOptions, + ) : undefined } /> diff --git a/packages/arcodesign/components/date-picker/type.ts b/packages/arcodesign/components/date-picker/type.ts index d94b4238..da5a7bec 100644 --- a/packages/arcodesign/components/date-picker/type.ts +++ b/packages/arcodesign/components/date-picker/type.ts @@ -125,5 +125,5 @@ export interface DatePickerProps * 将选择器的展现隐藏状态及选中值的展示与某个容器关联,传入后将同时渲染该容器和选择器组件,此时选择器组件的 visible 和 onHide 属性可不传,点击该容器会唤起选择器 * @en Associate the hidden state of the picker and the display of the selected value with a container. After passing it in, the container and the picker component will be rendered at the same time. At this time, the visible and onHide attributes of the picker component are optional values. Clicking the container will evoke the picker */ - renderLinkedContainer?: (currentTs: number, itemTypes: ItemType[]) => ReactNode; + renderLinkedContainer?: (currentTs: number | undefined, itemTypes: ItemType[]) => ReactNode; }