Skip to content

Commit

Permalink
fix: 修复最大时间约束不了时间范围选择器的结束时间问题 (#9154)
Browse files Browse the repository at this point in the history
  • Loading branch information
sqzhou authored Dec 18, 2023
1 parent 2e38351 commit e9a0d24
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/amis-ui/src/components/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ export class DateRangePicker extends React.Component<

// 根据 duration 修复结束时间
getEndDateByDuration(newValue: moment.Moment) {
const {minDuration, maxDuration, type} = this.props;
const {minDuration, maxDuration, type, maxDate} = this.props;
let {startDate, endDate, editState} = this.state;
if (!startDate) {
return newValue;
Expand All @@ -1152,6 +1152,10 @@ export class DateRangePicker extends React.Component<
newValue = startDate.clone().add(maxDuration);
}

if (maxDate && newValue && newValue.isAfter(maxDate, 'second')) {
newValue = maxDate;
}

return newValue;
}

Expand Down

0 comments on commit e9a0d24

Please sign in to comment.