Skip to content

Commit

Permalink
fix: keep empty value in renderLinkedContainer of DatePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
ziqisia committed Dec 12, 2024
1 parent 4a5c0f8 commit 26d5e02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/arcodesign/components/date-picker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -292,7 +292,11 @@ const DatePicker = forwardRef((props: DatePickerProps, ref: Ref<DatePickerRef>)
touchToStop={touchToStop}
renderLinkedContainer={
renderLinkedContainer
? () => renderLinkedContainer(currentTs, keyOptions)
? () =>
renderLinkedContainer(
isEmptyValue(props.currentTs) ? undefined : currentTs,
keyOptions,
)
: undefined
}
/>
Expand Down
2 changes: 1 addition & 1 deletion packages/arcodesign/components/date-picker/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 26d5e02

Please sign in to comment.