@@ -236,11 +236,7 @@ class Calendar extends UI5Element {
236
236
237
237
onBeforeRendering ( ) {
238
238
const oYearFormat = DateFormat . getDateInstance ( { format : "y" , calendarType : this . _primaryCalendarType } ) ;
239
- const minDateParsed = this . minDate && this . getFormat ( ) . parse ( this . minDate ) ;
240
- const maxDateParsed = this . maxDate && this . getFormat ( ) . parse ( this . maxDate ) ;
241
239
const firstDayOfCalendarTimeStamp = this . _getMinCalendarDate ( ) ;
242
- let currentMonth = 0 ;
243
- let currentYear = 1 ;
244
240
245
241
if ( ( this . minDate || this . maxDate ) && this . _timestamp && ! this . isInValidRange ( this . _timestamp * 1000 ) ) {
246
242
if ( this . _minDate ) {
@@ -258,8 +254,6 @@ class Calendar extends UI5Element {
258
254
this . _oMonth . maxDate = this . maxDate ;
259
255
this . _header . monthText = this . _oLocaleData . getMonths ( "wide" , this . _primaryCalendarType ) [ this . _month ] ;
260
256
this . _header . yearText = oYearFormat . format ( this . _localDate , true ) ;
261
- currentMonth = this . timestamp && CalendarDate . fromTimestamp ( this . timestamp * 1000 ) . getMonth ( ) ;
262
- currentYear = this . timestamp && CalendarDate . fromTimestamp ( this . timestamp * 1000 ) . getYear ( ) ;
263
257
264
258
// month picker
265
259
this . _monthPicker . primaryCalendarType = this . _primaryCalendarType ;
@@ -274,6 +268,18 @@ class Calendar extends UI5Element {
274
268
275
269
this . _isShiftingYears = false ;
276
270
271
+ this . _refreshNavigationButtonsState ( ) ;
272
+ }
273
+
274
+ _refreshNavigationButtonsState ( ) {
275
+ const minDateParsed = this . minDate && this . getFormat ( ) . parse ( this . minDate ) ;
276
+ const maxDateParsed = this . maxDate && this . getFormat ( ) . parse ( this . maxDate ) ;
277
+ let currentMonth = 0 ;
278
+ let currentYear = 1 ;
279
+
280
+ currentMonth = this . timestamp && CalendarDate . fromTimestamp ( this . timestamp * 1000 ) . getMonth ( ) ;
281
+ currentYear = this . timestamp && CalendarDate . fromTimestamp ( this . timestamp * 1000 ) . getYear ( ) ;
282
+
277
283
if ( ! this . _oMonth . _hidden ) {
278
284
if ( this . minDate
279
285
&& minDateParsed . getMonth ( ) === currentMonth
@@ -292,17 +298,36 @@ class Calendar extends UI5Element {
292
298
}
293
299
}
294
300
301
+ if ( ! this . _monthPicker . _hidden ) {
302
+ if ( this . minDate
303
+ && currentYear === minDateParsed . getFullYear ( ) ) {
304
+ this . _header . _isPrevButtonDisabled = true ;
305
+ } else {
306
+ this . _header . _isPrevButtonDisabled = false ;
307
+ }
308
+
309
+ if ( this . maxDate
310
+ && currentYear === maxDateParsed . getFullYear ( ) ) {
311
+ this . _header . _isNextButtonDisabled = true ;
312
+ } else {
313
+ this . _header . _isNextButtonDisabled = false ;
314
+ }
315
+ }
316
+
295
317
if ( ! this . _yearPicker . _hidden ) {
318
+ const cellsFromTheStart = 7 ;
319
+ const cellsToTheEnd = 12 ;
320
+
296
321
currentYear = this . _yearPicker . timestamp && CalendarDate . fromTimestamp ( this . _yearPicker . timestamp * 1000 ) . getYear ( ) ;
297
322
if ( this . minDate
298
- && ( currentYear - minDateParsed . getFullYear ( ) ) < 1 ) {
323
+ && ( currentYear - minDateParsed . getFullYear ( ) ) < cellsFromTheStart ) {
299
324
this . _header . _isPrevButtonDisabled = true ;
300
325
} else {
301
326
this . _header . _isPrevButtonDisabled = false ;
302
327
}
303
328
304
329
if ( this . maxDate
305
- && ( maxDateParsed . getFullYear ( ) - currentYear ) < 1 ) {
330
+ && ( maxDateParsed . getFullYear ( ) - currentYear ) < cellsToTheEnd ) {
306
331
this . _header . _isNextButtonDisabled = true ;
307
332
} else {
308
333
this . _header . _isNextButtonDisabled = false ;
0 commit comments