@@ -439,7 +439,7 @@ export class IgxGridSelectionService {
439439
440440 /** Select all rows, if filtering is applied select only from filtered data. */
441441 public selectAllRows ( event ?) {
442- const addedRows = this . allData . filter ( ( row ) => ! this . isRowSelected ( this . getRecordKey ( row ) ) ) ;
442+ const addedRows = this . allData . filter ( ( row ) => ! this . rowSelection . has ( this . getRecordKey ( row ) ) ) ;
443443 const selectedRows = this . getSelectedRowsData ( ) ;
444444 const newSelection = this . rowSelection . size ? selectedRows . concat ( addedRows ) : addedRows ;
445445 this . indeterminateRows . clear ( ) ;
@@ -616,10 +616,8 @@ export class IgxGridSelectionService {
616616 if ( this . allRowsSelected !== undefined && ! newSelection ) {
617617 return this . allRowsSelected ;
618618 }
619- const selectedData = new Set ( newSelection ? newSelection : [ ...this . rowSelection ] ) ;
620- const allData = this . getRowIDs ( this . allData ) ;
621- const unSelectedRows = allData . filter ( row => ! selectedData . has ( row ) ) ;
622- return this . allRowsSelected = this . allData . length > 0 && unSelectedRows . length === 0 ;
619+ const selectedData = new Set ( this . getRowIDs ( newSelection || this . rowSelection ) ) ;
620+ return this . allRowsSelected = this . allData . length > 0 && this . allData . every ( row => selectedData . has ( this . getRecordKey ( row ) ) ) ;
623621 }
624622
625623 public hasSomeRowSelected ( ) : boolean {
@@ -639,13 +637,16 @@ export class IgxGridSelectionService {
639637 if ( this . areEqualCollections ( currSelection , newSelection ) ) {
640638 return ;
641639 }
640+
642641 const args : IRowSelectionEventArgs = {
643642 owner : this . grid ,
644643 oldSelection : currSelection ,
645644 newSelection,
646- added, removed,
647- event, cancel : false ,
648- allRowsSelected : this . areAllRowSelected ( newSelection . map ( r => this . getRecordKey ( r ) ) )
645+ added,
646+ removed,
647+ event,
648+ cancel : false ,
649+ allRowsSelected : this . areAllRowSelected ( newSelection )
649650 } ;
650651
651652 this . grid . rowSelectionChanging . emit ( args ) ;
0 commit comments