@@ -543,6 +543,53 @@ describe('IgxGrid - Row Selection #grid', () => {
543543 }
544544 } ) ;
545545
546+ it ( 'Should select the correct rows with Shift + Click when grouping is activated' , ( ) => {
547+ expect ( grid . selectRowOnClick ) . toBe ( true ) ;
548+ spyOn ( grid . rowSelectionChanging , 'emit' ) . and . callThrough ( ) ;
549+
550+ grid . groupBy ( {
551+ fieldName : 'ProductName' , dir : SortingDirection . Desc , ignoreCase : false
552+ } ) ;
553+
554+ fix . detectChanges ( ) ;
555+
556+ const firstGroupRow = grid . gridAPI . get_row_by_index ( 1 ) ;
557+ const lastGroupRow = grid . gridAPI . get_row_by_index ( 4 ) ;
558+
559+ // Clicking on the first row within a group
560+ UIInteractions . simulateClickEvent ( firstGroupRow . nativeElement ) ;
561+ fix . detectChanges ( ) ;
562+
563+ GridSelectionFunctions . verifyRowSelected ( firstGroupRow ) ;
564+
565+ // Simulate Shift+Click on a row within another group
566+ const mockEvent = new MouseEvent ( 'click' , { shiftKey : true } ) ;
567+ lastGroupRow . nativeElement . dispatchEvent ( mockEvent ) ;
568+ fix . detectChanges ( ) ;
569+
570+ expect ( grid . selectedRows ) . toEqual ( [ 5 , 14 , 8 ] ) ; // ids
571+ expect ( grid . rowSelectionChanging . emit ) . toHaveBeenCalledTimes ( 2 ) ;
572+ expect ( grid . rowSelectionChanging . emit ) . toHaveBeenCalledWith ( {
573+ added : [ grid . dataView [ 2 ] , grid . dataView [ 4 ] ] ,
574+ cancel : false ,
575+ event : jasmine . anything ( ) ,
576+ newSelection : [ grid . dataView [ 1 ] , grid . dataView [ 2 ] , grid . dataView [ 4 ] ] ,
577+ oldSelection : [ grid . dataView [ 1 ] ] ,
578+ removed : [ ] ,
579+ allRowsSelected : false ,
580+ owner : grid
581+ } ) ;
582+
583+ const expectedSelectedRowIds = [ 5 , 14 , 8 ] ;
584+ grid . dataView . forEach ( ( rowData , index ) => {
585+ if ( expectedSelectedRowIds . includes ( rowData . ProductID ) ) {
586+ const row = grid . gridAPI . get_row_by_index ( index ) ;
587+ GridSelectionFunctions . verifyRowSelected ( row ) ;
588+ }
589+ } ) ;
590+
591+ } ) ;
592+
546593 it ( 'Should NOT select multiple rows with Shift + Click when selectRowOnClick has false value' , ( ) => {
547594 grid . selectRowOnClick = false ;
548595 spyOn ( grid . rowSelectionChanging , 'emit' ) . and . callThrough ( ) ;
0 commit comments