Skip to content

Commit 1777a9d

Browse files
authored
fix(Calendar): fix action button status error (#3996)
1 parent 1b57042 commit 1777a9d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

packages/components/calendar/calendar.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,16 @@ export default class Calendar extends SuperComponent {
167167
updateActionButton(value: Date) {
168168
const _min = this.getCurrentYearAndMonth(this.base.minDate);
169169
const _max = this.getCurrentYearAndMonth(this.base.maxDate);
170+
const _value = this.getCurrentYearAndMonth(value);
170171

171172
const _minTimestamp = new Date(_min.year, _min.month, 1).getTime();
172173
const _maxTimestamp = new Date(_max.year, _max.month, 1).getTime();
174+
const _dateValue = new Date(_value.year, _value.month, 1);
173175

174-
const _prevYearTimestamp = getPrevYear(value).getTime();
175-
const _prevMonthTimestamp = getPrevMonth(value).getTime();
176-
const _nextMonthTimestamp = getNextMonth(value).getTime();
177-
const _nextYearTimestamp = getNextYear(value).getTime();
176+
const _prevYearTimestamp = getPrevYear(_dateValue).getTime();
177+
const _prevMonthTimestamp = getPrevMonth(_dateValue).getTime();
178+
const _nextMonthTimestamp = getNextMonth(_dateValue).getTime();
179+
const _nextYearTimestamp = getNextYear(_dateValue).getTime();
178180

179181
const preYearBtnDisable = _prevYearTimestamp < _minTimestamp || _prevMonthTimestamp < _minTimestamp;
180182
const prevMonthBtnDisable = _prevMonthTimestamp < _minTimestamp;

packages/components/calendar/utils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
export function getMonthByOffset(date: Date, offset: number) {
22
const _date = new Date(date);
33
_date.setMonth(_date.getMonth() + offset);
4-
_date.setDate(1);
54
return _date;
65
}
76

87
export function getYearByOffset(date: Date, offset: number) {
98
const _date = new Date(date);
109
_date.setFullYear(_date.getFullYear() + offset);
11-
_date.setDate(1);
1210
return _date;
1311
}
1412

0 commit comments

Comments
 (0)