Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/big-apricots-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@alauda/ui": patch
---

fix: date picker nav availability check
15 changes: 9 additions & 6 deletions src/date-picker/calendar/header/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ export class CalendarHeaderComponent {
const availValue = (
side === Side.Left ? this._minAvail : this._maxAvail
)?.clone();
if (!availValue) {
return true;
}
/**
* 对于 range-picker
* 左侧部分 minAvail = minDate, maxAvail = min(maxData, rightAnchor),从而左侧部分的按钮,仅在小于右侧部分时显示
Expand All @@ -118,14 +121,14 @@ export class CalendarHeaderComponent {
return type === DateNavRange.Month
? !this.anchor.subtract(1, 'month').isBefore(availValue, 'month')
: type === DateNavRange.Year
? !this.anchor.subtract(1, 'year').isBefore(availValue, 'year')
: false;
? !this.anchor.subtract(1, 'year').isBefore(availValue, 'year')
: false;
}
return type === DateNavRange.Month
? !this.anchor.add(1, 'month').isAfter(availValue, 'month')
: type === DateNavRange.Year
? !this.anchor.add(1, 'year').isAfter(availValue, 'year')
: false;
? !this.anchor.add(1, 'year').isAfter(availValue, 'year')
: false;
}

// @return isBetween|isEqual:0, isBefore:-1,isAfter:1
Expand All @@ -141,8 +144,8 @@ export class CalendarHeaderComponent {
return constrainValue.isSame(range.start, MONTH)
? 0
: constrainValue.isBefore(range.start, MONTH)
? -1
: 1;
? -1
: 1;
}

navHead(range: DateNavRange, value: number) {
Expand Down