@@ -257,23 +257,31 @@ export class IgxDaysViewComponent extends IgxCalendarBase implements DoCheck {
257
257
const index = dates . indexOf ( node ) ;
258
258
259
259
if ( ! node ) { return ; }
260
+ this . nextDate = this . calendarModel . timedelta ( node . date . date , 'day' , - 7 ) ;
260
261
261
262
// focus item in current month
262
263
for ( let i = index ; i - 7 > - 1 ; i -= 7 ) {
263
- day = prevView ? node : dates [ i - 7 ] ;
264
+ day = prevView ? dates [ i ] : dates [ i - 7 ] ;
265
+ this . nextDate = day . date . date ;
266
+ if ( day . date . isPrevMonth ) {
267
+ break ;
268
+ }
264
269
if ( this . isDayFocusable ( day ) ) {
265
270
day . nativeElement . focus ( ) ;
266
- break ;
271
+ return ;
267
272
}
268
273
}
269
274
270
275
// focus item in previous visible month
271
- this . nextDate = this . calendarModel . timedelta ( node . date . date , 'day' , - 7 ) ;
272
- day = dates [ index - 7 ] ;
273
- if ( this . prevMonthView && ( ( day && day . date . isPrevMonth ) || ! day ) ) {
276
+ if ( this . prevMonthView ) {
274
277
dates = this . prevMonthView . dates . toArray ( ) ;
275
278
day = dates . find ( ( item ) => item . date . date . getTime ( ) === this . nextDate . getTime ( ) ) ;
276
- day . nativeElement . focus ( ) ;
279
+
280
+ if ( this . isDayFocusable ( day ) ) {
281
+ day . nativeElement . focus ( ) ;
282
+ return ;
283
+ }
284
+ this . prevMonthView . focusPreviousUpDate ( day . nativeElement ) ;
277
285
}
278
286
279
287
// focus item in next month, which is currently out of view
@@ -302,23 +310,31 @@ export class IgxDaysViewComponent extends IgxCalendarBase implements DoCheck {
302
310
const index = dates . indexOf ( node ) ;
303
311
304
312
if ( ! node ) { return ; }
313
+ this . nextDate = this . calendarModel . timedelta ( node . date . date , 'day' , 7 ) ;
305
314
306
315
// focus item in current month
307
316
for ( let i = index ; i + 7 < 42 ; i += 7 ) {
308
- day = nextView ? node : dates [ i + 7 ] ;
317
+ day = nextView ? dates [ i ] : dates [ i + 7 ] ;
318
+ this . nextDate = day . date . date ;
319
+ if ( day . date . isNextMonth ) {
320
+ break ;
321
+ }
309
322
if ( this . isDayFocusable ( day ) ) {
310
323
day . nativeElement . focus ( ) ;
311
- break ;
324
+ return ;
312
325
}
313
326
}
314
327
315
328
// focus item in next visible month
316
- this . nextDate = this . calendarModel . timedelta ( node . date . date , 'day' , 7 ) ;
317
- day = dates [ index + 7 ] ;
318
- if ( this . nextMonthView && ( ( day && day . date . isNextMonth ) || ! day ) ) {
329
+ if ( this . nextMonthView ) {
319
330
dates = this . nextMonthView . dates . toArray ( ) ;
320
331
day = dates . find ( ( item ) => item . date . date . getTime ( ) === this . nextDate . getTime ( ) ) ;
321
- day . nativeElement . focus ( ) ;
332
+
333
+ if ( this . isDayFocusable ( day ) ) {
334
+ day . nativeElement . focus ( ) ;
335
+ return ;
336
+ }
337
+ this . nextMonthView . focusNextDownDate ( day . nativeElement ) ;
322
338
}
323
339
324
340
// focus item in next month, which is currently out of view
@@ -349,22 +365,30 @@ export class IgxDaysViewComponent extends IgxCalendarBase implements DoCheck {
349
365
const index = dates . indexOf ( node ) ;
350
366
351
367
if ( ! node ) { return ; }
368
+ this . nextDate = this . calendarModel . timedelta ( node . date . date , 'day' , - 1 ) ;
352
369
353
370
for ( let i = index ; i > 0 ; i -- ) {
354
- day = prevView ? node : dates [ i - 1 ] ;
371
+ day = prevView ? dates [ i ] : dates [ i - 1 ] ;
372
+ this . nextDate = day . date . date ;
373
+ if ( day . date . isPrevMonth ) {
374
+ break ;
375
+ }
355
376
if ( this . isDayFocusable ( day ) ) {
356
377
day . nativeElement . focus ( ) ;
357
- break ;
378
+ return ;
358
379
}
359
380
}
360
381
361
382
// focus item in previous visible month
362
- this . nextDate = this . calendarModel . timedelta ( node . date . date , 'day' , - 1 ) ;
363
- day = dates [ index - 1 ] ;
364
- if ( this . prevMonthView && ( ( day && day . date . isPrevMonth ) || ! day ) ) {
383
+ if ( this . prevMonthView ) {
365
384
dates = this . prevMonthView . dates . toArray ( ) ;
366
385
day = dates . find ( ( item ) => item . date . date . getTime ( ) === this . nextDate . getTime ( ) ) ;
367
- day . nativeElement . focus ( ) ;
386
+
387
+ if ( this . isDayFocusable ( day ) ) {
388
+ day . nativeElement . focus ( ) ;
389
+ return ;
390
+ }
391
+ this . prevMonthView . focusPreviousDate ( day . nativeElement ) ;
368
392
}
369
393
370
394
// focus item in previous month, which is currently out of view
@@ -390,26 +414,35 @@ export class IgxDaysViewComponent extends IgxCalendarBase implements DoCheck {
390
414
const node = this . dates . find ( ( date ) => date . nativeElement === target ) ;
391
415
let dates = this . dates . toArray ( ) ,
392
416
day : IgxDayItemComponent ;
393
- const index = dates . indexOf ( node ) ;
417
+ let index = dates . indexOf ( node ) ;
394
418
395
419
if ( ! node ) { return ; }
420
+ this . nextDate = this . calendarModel . timedelta ( node . date . date , 'day' , 1 ) ;
396
421
397
422
// focus item in current month
398
423
for ( let i = index ; i < dates . length - 1 ; i ++ ) {
399
- day = nextView ? node : dates [ i + 1 ] ;
424
+ day = nextView ? dates [ i ] : dates [ i + 1 ] ;
425
+ this . nextDate = day . date . date ;
426
+ if ( day . date . isNextMonth ) {
427
+ break ;
428
+ }
400
429
if ( this . isDayFocusable ( day ) ) {
401
430
day . nativeElement . focus ( ) ;
402
- break ;
431
+ return ;
403
432
}
404
433
}
405
434
406
435
// focus item in next visible month
407
- this . nextDate = this . calendarModel . timedelta ( node . date . date , 'day' , 1 ) ;
408
- day = dates [ index + 1 ] ;
409
- if ( this . nextMonthView && ( ( day && day . date . isNextMonth ) || ! day ) ) {
436
+ if ( this . nextMonthView ) {
410
437
dates = this . nextMonthView . dates . toArray ( ) ;
411
438
day = dates . find ( ( item ) => item . date . date . getTime ( ) === this . nextDate . getTime ( ) ) ;
412
- day . nativeElement . focus ( ) ;
439
+ index = dates . indexOf ( day ) ;
440
+
441
+ if ( this . isDayFocusable ( day ) ) {
442
+ day . nativeElement . focus ( ) ;
443
+ return ;
444
+ }
445
+ this . nextMonthView . focusNextDate ( day . nativeElement ) ;
413
446
}
414
447
415
448
// focus item in next month, which is currently out of view
0 commit comments