Skip to content

Commit 3e65c73

Browse files
Merge pull request #16116 from IgniteUI/mkirkova/fix-16069-master
Prevent emitting selected event for already selected cells in hierarchical grid - master
2 parents dd5ba17 + ed04b9d commit 3e65c73

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-cell.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ export class IgxHierarchicalGridCellComponent extends IgxGridCellComponent imple
9191
private _clearAllHighlights() {
9292
[this._rootGrid, ...this._rootGrid.getChildGrids(true)].forEach(grid => {
9393
if (grid !== this.grid && grid.navigation.activeNode) {
94+
grid.selectionService.activeElement = null;
9495
grid.navigation.clearActivation();
9596
grid.selectionService.initKeyboardState();
9697
grid.selectionService.clear();
9798
}
9899

99-
grid.selectionService.activeElement = null;
100100
grid.nativeElement.classList.remove('igx-grid__tr--highlighted');
101101
grid.highlightedRowID = null;
102102
grid.cdr.markForCheck();

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid.selection.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,19 @@ describe('IgxHierarchicalGrid selection #hGrid', () => {
7878
expect(fCell.selected).toBeFalsy();
7979

8080
// select parent cell
81+
const parentSpy = spyOn<any>(hierarchicalGrid.selected, 'emit').and.callThrough();
8182
firstRow = hierarchicalGrid.gridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
8283
fCell = firstRow.cells.toArray()[0];
8384
GridFunctions.focusCell(fix, fCell);
8485
fix.detectChanges();
8586
expect(fChildCell.selected).toBeFalsy();
8687
expect(fCell.selected).toBeTruthy();
88+
expect(parentSpy).toHaveBeenCalledTimes(1);
89+
90+
GridFunctions.focusCell(fix, fCell);
91+
fix.detectChanges();
92+
expect(fCell.selected).toBeTruthy();
93+
expect(parentSpy).toHaveBeenCalledTimes(1);
8794
});
8895

8996
it('should be able to set cellSelection mode per grid', () => {

0 commit comments

Comments
 (0)