From 240d02ecc7e8974dec6c42303212795f63bfb8b9 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Mon, 4 Mar 2024 17:35:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(Date-picker):=20=E4=BF=AE=E5=A4=8D=E5=8F=97?= =?UTF-8?q?=E6=8E=A7=E6=A8=A1=E5=BC=8F=E4=B8=8B=E8=AE=BE=E7=BD=AE=20showTi?= =?UTF-8?q?me=20=E5=90=8E=E4=BA=A4=E4=BA=92=E5=92=8C=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20(#2757)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/itchy-pigs-promise.md | 5 +++++ .changeset/poor-camels-protect.md | 5 +++++ .../ui/date-picker/src/components/root.tsx | 22 ++++++++++--------- 3 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 .changeset/itchy-pigs-promise.md create mode 100644 .changeset/poor-camels-protect.md 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