diff --git a/.changeset/itchy-pigs-promise.md b/.changeset/itchy-pigs-promise.md new file mode 100644 index 000000000..fcf298ba7 --- /dev/null +++ b/.changeset/itchy-pigs-promise.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +fix(date-picker): 修复受控模式下设置 showTime 后 Input 框没有实时显示选择的值问题 diff --git a/.changeset/poor-camels-protect.md b/.changeset/poor-camels-protect.md new file mode 100644 index 000000000..183d276bc --- /dev/null +++ b/.changeset/poor-camels-protect.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/date-picker": patch +--- + +fix: 修复受控模式下设置 showTime 后 Input 框没有实时显示选择的值问题 diff --git a/packages/ui/date-picker/src/components/root.tsx b/packages/ui/date-picker/src/components/root.tsx index 249aaefd8..aeab9c552 100644 --- a/packages/ui/date-picker/src/components/root.tsx +++ b/packages/ui/date-picker/src/components/root.tsx @@ -56,17 +56,19 @@ const Root = ({ useEffect(() => { setInputData( - value - ? parseValue( - value, - type, - weekOffset, - typeof format === 'string' ? format : undefined, - strideSelectMode - ) - : outDate + parseValue( + value, + type, + weekOffset, + typeof format === 'string' ? format : undefined, + strideSelectMode + ) ) - }, [value, format, type, outDate, weekOffset, strideSelectMode]) + }, [value, format, type, weekOffset, strideSelectMode]) + + useEffect(() => { + setInputData(outDate) + }, [outDate]) const onPickerClickEvent = (index: number) => { if (disabled) return