Skip to content

Commit

Permalink
fix(AbsoluteRangePicker): fix AbsoluteRangePicker defaultViewDates er…
Browse files Browse the repository at this point in the history
…ror (#1866)

* fix(absoluterangepicker): fix AbsoluteRangePicker defaultViewDates error

fix Pastimepicker defaultViewDates display error

* fix(static-past-time-picker): fix build error
  • Loading branch information
gavin-hao committed Feb 28, 2022
1 parent 0c1e1fa commit e670180
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/static-past-time-picker/AbsoluteRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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 = dates[1] !== undefined && isValid(dates[1]) ? dates[1] : new Date();
return (
<InnerRangePanel
disableOK={!isValid(dates[0]) || !isValid(dates[1])}
header={renderHeader()}
body={
<StaticDateRangePicker
defaultViewDates={[subMonths(startOfToday(), 1), startOfToday()]}
defaultViewDates={[subMonths(startOfDay(endDay), 1), startOfDay(endDay)]}
disabledDate={handleDisabledDate}
onSelect={handleOnSelect}
value={dates as [Date, Date]}
Expand Down

1 comment on commit e670180

@vercel
Copy link

@vercel vercel bot commented on e670180 Feb 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.