From 8bab477cc94f935c146079cd4574f36f7551ca25 Mon Sep 17 00:00:00 2001 From: haozhigang Date: Fri, 25 Feb 2022 20:26:48 +0800 Subject: [PATCH 1/2] fix(absoluterangepicker): fix AbsoluteRangePicker defaultViewDates error fix Pastimepicker defaultViewDates display error --- src/static-past-time-picker/AbsoluteRangePicker.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/static-past-time-picker/AbsoluteRangePicker.tsx b/src/static-past-time-picker/AbsoluteRangePicker.tsx index 76dcd859c0..3c7474e6e1 100644 --- a/src/static-past-time-picker/AbsoluteRangePicker.tsx +++ b/src/static-past-time-picker/AbsoluteRangePicker.tsx @@ -8,7 +8,7 @@ import { RangePickerProps } from './interfaces'; import { parseStartAndEndDate } from './utils'; import defaultLocale from './locales/zh-CN'; -function AbsoluteRangePicker({ disabledDate, timeRange, onSelect,onRangeSelect, onCancel }: RangePickerProps) { +function AbsoluteRangePicker({ disabledDate, timeRange, onSelect, onRangeSelect, onCancel }: RangePickerProps) { const [dates, setDates] = React.useState<[Date | undefined, Date | undefined]>(parseStartAndEndDate(timeRange)); const prefixCls = usePrefixCls('range-panel__header'); @@ -32,15 +32,16 @@ function AbsoluteRangePicker({ disabledDate, timeRange, onSelect,onRangeSelect, }; const handleOnSelect = (date: [Date, Date], index: number) => { setDates(date); - onRangeSelect?.(date,index); + onRangeSelect?.(date, index); } + const endDay = isValid(dates[1]) ? dates[1] : new Date(); return ( Date: Mon, 28 Feb 2022 11:05:54 +0800 Subject: [PATCH 2/2] fix(static-past-time-picker): fix build error --- src/static-past-time-picker/AbsoluteRangePicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/static-past-time-picker/AbsoluteRangePicker.tsx b/src/static-past-time-picker/AbsoluteRangePicker.tsx index 3c7474e6e1..40eab4c2e4 100644 --- a/src/static-past-time-picker/AbsoluteRangePicker.tsx +++ b/src/static-past-time-picker/AbsoluteRangePicker.tsx @@ -34,7 +34,7 @@ function AbsoluteRangePicker({ disabledDate, timeRange, onSelect, onRangeSelect, setDates(date); onRangeSelect?.(date, index); } - const endDay = isValid(dates[1]) ? dates[1] : new Date(); + const endDay = dates[1] !== undefined && isValid(dates[1]) ? dates[1] : new Date(); return (