@@ -8,7 +8,7 @@ import { IgxGridModule } from './index';
8
8
import { IgxGridComponent } from './grid.component' ;
9
9
import { IgxGridRowComponent } from './grid-row.component' ;
10
10
import { SampleTestData } from '../../test-utils/sample-test-data.spec' ;
11
- import { GridFunctions } from '../../test-utils/grid-functions.spec' ;
11
+ import { GridFunctions , GridSelectionFunctions } from '../../test-utils/grid-functions.spec' ;
12
12
import { IgxGridExpandableCellComponent } from './expandable-cell.component' ;
13
13
14
14
const COLLAPSED_ICON_NAME = 'chevron_right' ;
@@ -325,6 +325,7 @@ describe('IgxGrid Master Detail #grid', () => {
325
325
fix . detectChanges ( ) ;
326
326
expect ( grid . rowList . first . cells . first instanceof IgxGridExpandableCellComponent ) . toBeTruthy ( ) ;
327
327
} ) ;
328
+
328
329
it ( 'Should keep the expand/collapse icon in the first column, even when moving a column out of first place.' , ( ) => {
329
330
fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
330
331
grid = fix . componentInstance . grid ;
@@ -334,6 +335,49 @@ describe('IgxGrid Master Detail #grid', () => {
334
335
expect ( grid . rowList . first . cells . first instanceof IgxGridExpandableCellComponent ) . toBeTruthy ( ) ;
335
336
} ) ;
336
337
} ) ;
338
+
339
+ describe ( 'Cell Selection' , ( ) => {
340
+ it ( 'Should exclude expanded detail views when doing range cell selection' , ( ) => {
341
+ fix = TestBed . createComponent ( DefaultGridMasterDetailComponent ) ;
342
+ grid = fix . componentInstance . grid ;
343
+ fix . detectChanges ( ) ;
344
+ grid . expand ( fix . componentInstance . data [ 2 ] . ID ) ;
345
+ const selectionChangeSpy = spyOn < any > ( grid . onRangeSelection , 'emit' ) . and . callThrough ( ) ;
346
+ const startCell = grid . getCellByColumn ( 1 , 'ContactName' ) ;
347
+ const endCell = grid . getCellByColumn ( 6 , 'CompanyName' ) ;
348
+ const range = { rowStart : 1 , rowEnd : 6 , columnStart : 0 , columnEnd : 1 } ;
349
+
350
+ UIInteractions . simulatePointerOverCellEvent ( 'pointerdown' , startCell . nativeElement ) ;
351
+ startCell . nativeElement . dispatchEvent ( new Event ( 'focus' ) ) ;
352
+ grid . cdr . detectChanges ( ) ;
353
+
354
+ expect ( startCell . focused ) . toBe ( true ) ;
355
+
356
+ const rowDetail = GridFunctions . getMasterRowDetail ( grid . rowList . toArray ( ) [ 2 ] ) ;
357
+
358
+ for ( let i = 2 ; i < 6 ; i ++ ) {
359
+ const cell = grid . getCellByColumn ( i , 'ContactName' ) ;
360
+ if ( ! cell ) {
361
+ UIInteractions . simulatePointerOverCellEvent ( 'pointerenter' ,
362
+ fix . debugElement . query ( By . css ( '.addressArea' ) ) . nativeElement ) ;
363
+ continue ;
364
+ }
365
+ UIInteractions . simulatePointerOverCellEvent ( 'pointerenter' , cell . nativeElement ) ;
366
+ grid . cdr . detectChanges ( ) ;
367
+ }
368
+ UIInteractions . simulatePointerOverCellEvent ( 'pointerenter' , endCell . nativeElement ) ;
369
+ UIInteractions . simulatePointerOverCellEvent ( 'pointerup' , endCell . nativeElement ) ;
370
+ GridSelectionFunctions . verifyCellsRegionSelected ( grid , 1 , 2 , 0 , 1 , true ) ;
371
+ GridSelectionFunctions . verifyCellsRegionSelected ( grid , 4 , 5 , 0 , 1 , true ) ;
372
+ grid . cdr . detectChanges ( ) ;
373
+
374
+ expect ( startCell . focused ) . toBe ( true ) ;
375
+
376
+ expect ( selectionChangeSpy ) . toHaveBeenCalledTimes ( 1 ) ;
377
+ expect ( selectionChangeSpy ) . toHaveBeenCalledWith ( range ) ;
378
+ expect ( rowDetail . querySelector ( '[class*="selected"]' ) ) . toBeNull ( ) ;
379
+ } ) ;
380
+ } ) ;
337
381
} ) ;
338
382
} ) ;
339
383
0 commit comments