From 61e4806314328ed6d381d6b790b1d11f6f5500a7 Mon Sep 17 00:00:00 2001 From: Artur Yorsh <10753921+artyorsh@users.noreply.github.com> Date: Fri, 18 Oct 2019 13:58:11 +0300 Subject: [PATCH] fix(ui): calendar - date bounds disabling behavior --- .../ui/calendar/baseCalendar.component.tsx | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/framework/ui/calendar/baseCalendar.component.tsx b/src/framework/ui/calendar/baseCalendar.component.tsx index 1ac6f508f..95ece7f2d 100644 --- a/src/framework/ui/calendar/baseCalendar.component.tsx +++ b/src/framework/ui/calendar/baseCalendar.component.tsx @@ -259,15 +259,33 @@ export abstract class BaseCalendarComponent extends React.Component): boolean => { - return !this.isDateFitsBounds(date) || this.isDateFitsFilter(date); + const minDayStart: D = this.dateService.createDate( + this.dateService.getYear(this.min), + this.dateService.getMonth(this.min), + this.dateService.getDate(this.min), + ); + + const maxDayStart: D = this.dateService.createDate( + this.dateService.getYear(this.max), + this.dateService.getMonth(this.max), + this.dateService.getDate(this.max), + ); + + return !this.dateService.isBetweenIncludingSafe(date.date, minDayStart, maxDayStart) || this.isDateFitsFilter(date); }; private isMonthDisabled = (date: CalendarDateInfo): boolean => { - return !this.isDateFitsBounds(date) || this.isDateFitsFilter(date); + const minMonthStart: D = this.dateService.getMonthStart(this.min); + const maxMonthStart: D = this.dateService.getMonthStart(this.max); + + return !this.dateService.isBetweenIncludingSafe(date.date, minMonthStart, maxMonthStart); }; private isYearDisabled = (date: CalendarDateInfo): boolean => { - return !this.isDateFitsBounds(date) || this.isDateFitsFilter(date); + const minYearStart: D = this.dateService.getYearStart(this.min); + const maxYearStart: D = this.dateService.getYearEnd(this.max); + + return !this.dateService.isBetweenIncludingSafe(date.date, minYearStart, maxYearStart); }; public isDayToday = (date: CalendarDateInfo): boolean => {