Skip to content

Commit 7e3f546

Browse files
ypzhaofengtianze
authored andcommitted
fix: date picker nav availability check
1 parent dea9672 commit 7e3f546

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

.changeset/big-apricots-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@alauda/ui": patch
3+
---
4+
5+
fix: date picker nav availability check

src/date-picker/calendar/header/component.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ export class CalendarHeaderComponent {
109109
const availValue = (
110110
side === Side.Left ? this._minAvail : this._maxAvail
111111
)?.clone();
112+
if (!availValue) {
113+
return true;
114+
}
112115
/**
113116
* 对于 range-picker
114117
* 左侧部分 minAvail = minDate, maxAvail = min(maxData, rightAnchor),从而左侧部分的按钮,仅在小于右侧部分时显示
@@ -118,14 +121,14 @@ export class CalendarHeaderComponent {
118121
return type === DateNavRange.Month
119122
? !this.anchor.subtract(1, 'month').isBefore(availValue, 'month')
120123
: type === DateNavRange.Year
121-
? !this.anchor.subtract(1, 'year').isBefore(availValue, 'year')
122-
: false;
124+
? !this.anchor.subtract(1, 'year').isBefore(availValue, 'year')
125+
: false;
123126
}
124127
return type === DateNavRange.Month
125128
? !this.anchor.add(1, 'month').isAfter(availValue, 'month')
126129
: type === DateNavRange.Year
127-
? !this.anchor.add(1, 'year').isAfter(availValue, 'year')
128-
: false;
130+
? !this.anchor.add(1, 'year').isAfter(availValue, 'year')
131+
: false;
129132
}
130133

131134
// @return isBetween|isEqual:0, isBefore:-1,isAfter:1
@@ -141,8 +144,8 @@ export class CalendarHeaderComponent {
141144
return constrainValue.isSame(range.start, MONTH)
142145
? 0
143146
: constrainValue.isBefore(range.start, MONTH)
144-
? -1
145-
: 1;
147+
? -1
148+
: 1;
146149
}
147150

148151
navHead(range: DateNavRange, value: number) {

0 commit comments

Comments
 (0)