Skip to content

Commit 61e4806

Browse files
authored
fix(ui): calendar - date bounds disabling behavior
1 parent bc4ceb1 commit 61e4806

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/framework/ui/calendar/baseCalendar.component.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,33 @@ export abstract class BaseCalendarComponent<D, P> extends React.Component<BaseCa
259259
};
260260

261261
public isDayDisabled = (date: CalendarDateInfo<D>): boolean => {
262-
return !this.isDateFitsBounds(date) || this.isDateFitsFilter(date);
262+
const minDayStart: D = this.dateService.createDate(
263+
this.dateService.getYear(this.min),
264+
this.dateService.getMonth(this.min),
265+
this.dateService.getDate(this.min),
266+
);
267+
268+
const maxDayStart: D = this.dateService.createDate(
269+
this.dateService.getYear(this.max),
270+
this.dateService.getMonth(this.max),
271+
this.dateService.getDate(this.max),
272+
);
273+
274+
return !this.dateService.isBetweenIncludingSafe(date.date, minDayStart, maxDayStart) || this.isDateFitsFilter(date);
263275
};
264276

265277
private isMonthDisabled = (date: CalendarDateInfo<D>): boolean => {
266-
return !this.isDateFitsBounds(date) || this.isDateFitsFilter(date);
278+
const minMonthStart: D = this.dateService.getMonthStart(this.min);
279+
const maxMonthStart: D = this.dateService.getMonthStart(this.max);
280+
281+
return !this.dateService.isBetweenIncludingSafe(date.date, minMonthStart, maxMonthStart);
267282
};
268283

269284
private isYearDisabled = (date: CalendarDateInfo<D>): boolean => {
270-
return !this.isDateFitsBounds(date) || this.isDateFitsFilter(date);
285+
const minYearStart: D = this.dateService.getYearStart(this.min);
286+
const maxYearStart: D = this.dateService.getYearEnd(this.max);
287+
288+
return !this.dateService.isBetweenIncludingSafe(date.date, minYearStart, maxYearStart);
271289
};
272290

273291
public isDayToday = (date: CalendarDateInfo<D>): boolean => {

0 commit comments

Comments
 (0)