@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
2
2
import { first } from 'rxjs/operators' ;
3
3
import { IgxForOfDirective } from '../directives/for-of/for_of.directive' ;
4
4
import { GridType } from './common/grid.interface' ;
5
- import { NAVIGATION_KEYS , ROW_COLLAPSE_KEYS , ROW_EXPAND_KEYS , SUPPORTED_KEYS , HORIZONTAL_NAV_KEYS , HEADER_KEYS , isEdge } from '../core/utils' ;
5
+ import { NAVIGATION_KEYS , ROW_COLLAPSE_KEYS , ROW_EXPAND_KEYS , SUPPORTED_KEYS , HORIZONTAL_NAV_KEYS , HEADER_KEYS , ROW_ADD_KEYS , isEdge } from '../core/utils' ;
6
6
import { IgxGridBaseDirective } from './grid-base.directive' ;
7
7
import { IMultiRowLayoutNode } from './selection/selection.service' ;
8
8
import { GridKeydownTargetType , GridSelectionMode , FilterMode } from './common/enums' ;
@@ -92,7 +92,7 @@ export class IgxGridNavigationService {
92
92
this . grid . verticalScrollContainer . onChunkLoad
93
93
. pipe ( first ( ) ) . subscribe ( ( ) => {
94
94
if ( editCell && this . grid . rowList . map ( r => r . index ) . indexOf ( editCell . rowIndex ) < 0 ) {
95
- this . grid . tbody . nativeElement . focus ( { preventScroll : true } ) ;
95
+ this . grid . tbody . nativeElement . focus ( { preventScroll : true } ) ;
96
96
}
97
97
} ) ;
98
98
break ;
@@ -214,7 +214,7 @@ export class IgxGridNavigationService {
214
214
newActiveNode . mchCache . visibleIndex = column . visibleIndex ;
215
215
}
216
216
217
- this . setActiveNode ( { row : this . activeNode . row , column : newActiveNode . column , mchCache : newActiveNode . mchCache } ) ;
217
+ this . setActiveNode ( { row : this . activeNode . row , column : newActiveNode . column , mchCache : newActiveNode . mchCache } ) ;
218
218
this . performHorizontalScrollToCell ( this . activeNode . column ) ;
219
219
}
220
220
@@ -232,10 +232,12 @@ export class IgxGridNavigationService {
232
232
focusFirstCell ( header = true ) {
233
233
if ( ( header || this . grid . dataView . length ) && this . activeNode &&
234
234
( this . activeNode . row === - 1 || this . activeNode . row === this . grid . dataView . length ||
235
- ( ! header && ! this . grid . hasSummarizedColumns ) ) ) { return ; }
235
+ ( ! header && ! this . grid . hasSummarizedColumns ) ) ) { return ; }
236
236
237
- this . setActiveNode ( { row : header ? - 1 : this . grid . dataView . length , column : 0 ,
238
- level : this . grid . hasColumnLayouts ? 1 : 0 , mchCache : { level : 0 , visibleIndex : 0 } } ) ;
237
+ this . setActiveNode ( {
238
+ row : header ? - 1 : this . grid . dataView . length , column : 0 ,
239
+ level : this . grid . hasColumnLayouts ? 1 : 0 , mchCache : { level : 0 , visibleIndex : 0 }
240
+ } ) ;
239
241
this . performHorizontalScrollToCell ( 0 ) ;
240
242
}
241
243
@@ -327,7 +329,7 @@ export class IgxGridNavigationService {
327
329
if ( this . grid . rowInEditMode && ! this . grid . rowEditTabs . length ) {
328
330
if ( shift && next . rowIndex === this . activeNode . row && next . visibleColumnIndex === this . activeNode . column ) {
329
331
next . visibleColumnIndex = this . grid . lastEditableColumnIndex ;
330
- } else if ( ! shift && next . rowIndex === this . activeNode . row && next . visibleColumnIndex === this . activeNode . column ) {
332
+ } else if ( ! shift && next . rowIndex === this . activeNode . row && next . visibleColumnIndex === this . activeNode . column ) {
331
333
next . visibleColumnIndex = this . grid . firstEditableColumnIndex ;
332
334
} else {
333
335
next . rowIndex = this . activeNode . row ;
@@ -360,7 +362,7 @@ export class IgxGridNavigationService {
360
362
// this is workaround: endTopOffset - containerHeight > 5 and should be replaced with: containerHeight < endTopOffset
361
363
// when the page is zoomed the grid does not scroll the row completely in the view
362
364
return ! targetRow || targetRow . offsetTop < Math . abs ( this . containerTopOffset )
363
- || containerHeight && endTopOffset - containerHeight > 5 ;
365
+ || containerHeight && endTopOffset - containerHeight > 5 ;
364
366
}
365
367
366
368
protected navigateInBody ( rowIndex , visibleColIndex , cb : Function = null ) : void {
@@ -415,8 +417,8 @@ export class IgxGridNavigationService {
415
417
const currRow = this . grid . dataView [ activeNode . row ] ;
416
418
const type : GridKeydownTargetType = activeNode . row < 0 ? 'headerCell' :
417
419
this . isDataRow ( activeNode . row ) ? 'dataCell' :
418
- currRow && this . grid . isGroupByRecord ( currRow ) ? 'groupRow' :
419
- currRow && this . grid . isDetailRecord ( currRow ) ? 'masterDetailRow' : 'summaryCell' ;
420
+ currRow && this . grid . isGroupByRecord ( currRow ) ? 'groupRow' :
421
+ currRow && this . grid . isDetailRecord ( currRow ) ? 'masterDetailRow' : 'summaryCell' ;
420
422
421
423
const args : IActiveNodeChangeEventArgs = {
422
424
row : this . activeNode . row ,
@@ -491,7 +493,7 @@ export class IgxGridNavigationService {
491
493
}
492
494
493
495
protected findLastDataRowIndex ( ) : number {
494
- if ( ( this . grid as any ) . totalItemCount ) { return ( this . grid as any ) . totalItemCount - 1 ; }
496
+ if ( ( this . grid as any ) . totalItemCount ) { return ( this . grid as any ) . totalItemCount - 1 ; }
495
497
let i = this . grid . dataView . length ;
496
498
while ( i -- ) {
497
499
if ( this . isDataRow ( i ) ) {
@@ -516,15 +518,15 @@ export class IgxGridNavigationService {
516
518
return this . activeNode . column !== colIndex && ! this . isDataRow ( rowIndex , true ) ? false : true ;
517
519
}
518
520
protected performHeaderKeyCombination ( column , key , shift , ctrl , alt , event ) {
519
- let direction = this . grid . sortingExpressions . find ( expr => expr . fieldName === column . field ) ?. dir ;
521
+ let direction = this . grid . sortingExpressions . find ( expr => expr . fieldName === column . field ) ?. dir ;
520
522
if ( ctrl && key . includes ( 'up' ) && column . sortable && ! column . columnGroup ) {
521
523
direction = direction === SortingDirection . Asc ? SortingDirection . None : SortingDirection . Asc ;
522
- this . grid . sort ( { fieldName : column . field , dir : direction , ignoreCase : false } ) ;
524
+ this . grid . sort ( { fieldName : column . field , dir : direction , ignoreCase : false } ) ;
523
525
return ;
524
526
}
525
527
if ( ctrl && key . includes ( 'down' ) && column . sortable && ! column . columnGroup ) {
526
528
direction = direction === SortingDirection . Desc ? SortingDirection . None : SortingDirection . Desc ;
527
- this . grid . sort ( { fieldName : column . field , dir : direction , ignoreCase : false } ) ;
529
+ this . grid . sort ( { fieldName : column . field , dir : direction , ignoreCase : false } ) ;
528
530
return ;
529
531
}
530
532
if ( shift && alt && this . isToggleKey ( key ) && ! column . columnGroup && column . groupable ) {
@@ -564,16 +566,16 @@ export class IgxGridNavigationService {
564
566
} ;
565
567
const activeCol = this . currentActiveColumn ;
566
568
const lastGroupIndex = Math . max ( ... this . grid . visibleColumns .
567
- filter ( c => c . level <= this . activeNode . level ) . map ( col => col . visibleIndex ) ) ;
569
+ filter ( c => c . level <= this . activeNode . level ) . map ( col => col . visibleIndex ) ) ;
568
570
let nextCol = activeCol ;
569
571
if ( ( key . includes ( 'left' ) || key === 'home' ) && this . activeNode . column > 0 ) {
570
572
const index = ctrl || key === 'home' ? 0 : this . activeNode . column - 1 ;
571
- nextCol = this . getNextColumnMCH ( index ) ;
573
+ nextCol = this . getNextColumnMCH ( index ) ;
572
574
newHeaderNode . visibleIndex = nextCol . visibleIndex ;
573
575
}
574
576
if ( ( key . includes ( 'right' ) || key === 'end' ) && activeCol . visibleIndex < lastGroupIndex ) {
575
577
const nextVIndex = activeCol . children ? Math . max ( ...activeCol . allChildren . map ( c => c . visibleIndex ) ) + 1 :
576
- activeCol . visibleIndex + 1 ;
578
+ activeCol . visibleIndex + 1 ;
577
579
nextCol = ctrl || key === 'end' ? this . getNextColumnMCH ( this . lastColumnIndex ) : this . getNextColumnMCH ( nextVIndex ) ;
578
580
newHeaderNode . visibleIndex = nextCol . visibleIndex ;
579
581
}
@@ -583,16 +585,17 @@ export class IgxGridNavigationService {
583
585
}
584
586
if ( ! ctrl && key . includes ( 'down' ) && activeCol . children ) {
585
587
nextCol = activeCol . children . find ( c => c . visibleIndex === newHeaderNode . visibleIndex ) ||
586
- activeCol . children . toArray ( ) . sort ( ( a , b ) => b . visibleIndex - a . visibleIndex )
587
- . filter ( col => col . visibleIndex < newHeaderNode . visibleIndex ) [ 0 ] ;
588
+ activeCol . children . toArray ( ) . sort ( ( a , b ) => b . visibleIndex - a . visibleIndex )
589
+ . filter ( col => col . visibleIndex < newHeaderNode . visibleIndex ) [ 0 ] ;
588
590
newHeaderNode . level = nextCol . level ;
589
591
}
590
592
591
593
this . setActiveNode ( {
592
594
row : this . activeNode . row ,
593
595
column : nextCol . visibleIndex ,
594
596
level : nextCol . level ,
595
- mchCache : newHeaderNode } ) ;
597
+ mchCache : newHeaderNode
598
+ } ) ;
596
599
this . performHorizontalScrollToCell ( nextCol . visibleIndex ) ;
597
600
}
598
601
@@ -606,12 +609,12 @@ export class IgxGridNavigationService {
606
609
}
607
610
608
611
private handleColumnSelection ( column , event ) {
609
- if ( ! column . selectable || this . grid . columnSelection === GridSelectionMode . none ) { return ; }
612
+ if ( ! column . selectable || this . grid . columnSelection === GridSelectionMode . none ) { return ; }
610
613
const clearSelection = this . grid . columnSelection === GridSelectionMode . single ;
611
614
const columnsToSelect = ! column . children ? [ column . field ] :
612
615
column . allChildren . filter ( c => ! c . hidden && c . selectable && ! c . columnGroup ) . map ( c => c . field ) ;
613
616
column . selected ? this . grid . selectionService . deselectColumns ( columnsToSelect , event ) :
614
- this . grid . selectionService . selectColumns ( columnsToSelect , clearSelection , false , event ) ;
617
+ this . grid . selectionService . selectColumns ( columnsToSelect , clearSelection , false , event ) ;
615
618
}
616
619
617
620
private getNextColumnMCH ( visibleIndex ) {
@@ -637,6 +640,6 @@ export class IgxGridNavigationService {
637
640
}
638
641
639
642
private isAddKey ( key : string ) : boolean {
640
- return key === '+' || key === 'add' ; // add is for IE and Edge
643
+ return ROW_ADD_KEYS . has ( key ) ;
641
644
}
642
645
}
0 commit comments