From ca01e9c3cea625839aa1255cf7c5e3f1b8e849b6 Mon Sep 17 00:00:00 2001 From: zhouzheng Date: Tue, 10 May 2022 10:02:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(DateInputRange):=20=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E4=B8=AD=E4=BD=BF=E7=94=A8=E6=B8=85=E9=99=A4=E6=97=A0=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/react-date-input/README.md | 5 +++-- packages/react-date-input/src/DateInputRange.tsx | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/react-date-input/README.md b/packages/react-date-input/README.md index 34ccc8f98f..477c9de4e9 100644 --- a/packages/react-date-input/README.md +++ b/packages/react-date-input/README.md @@ -91,12 +91,12 @@ function Demo(){ if (current.date) { Notify.success({ title: '提交成功!', - description: `表单提交时间成功,时间为:${current.date}`, + description: `表单提交时间成功,时间为:${current.date} range:${current.dateRange}`, }); } else { Notify.error({ title: '提交失败!', - description: `表单提交时间成功,时间为:${current.date},将自动填充初始化值!`, + description: `表单提交时间成功,时间为:${current.date} range:${current.dateRange},将自动填充初始化值!`, }); } }} @@ -123,6 +123,7 @@ function Demo(){ {fields.dateRange} + {JSON.stringify(state)} diff --git a/packages/react-date-input/src/DateInputRange.tsx b/packages/react-date-input/src/DateInputRange.tsx index 3c59b6f050..6319819007 100644 --- a/packages/react-date-input/src/DateInputRange.tsx +++ b/packages/react-date-input/src/DateInputRange.tsx @@ -50,6 +50,11 @@ export function DateInputRange(props: DateInputRangePro onChange && onChange(cdate, changeValue); } + function clearDateRange() { + setDateRange([]); + onChange && onChange(undefined, []); + } + return (
(props: DateInputRangePro /> {allowClear && dateRange.length > 0 && ( - setDateRange([])} type="close" /> + clearDateRange()} type="close" /> )}
);