Skip to content

Commit 5aa3af7

Browse files
authored
Merge pull request #8141 from IgniteUI/ddincheva/selectionHGrid-9.1
Enhance multi-cell selection in hierarchical grid -- 9.1.x
2 parents d4b865c + de08a80 commit 5aa3af7

File tree

4 files changed

+427
-6
lines changed

4 files changed

+427
-6
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,11 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
778778
* @internal
779779
*/
780780
pointerenter = (event: PointerEvent) => {
781+
const isHierarchicalGrid = this.grid.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid';
782+
if (!this.grid.navigation.activeNode ||
783+
(isHierarchicalGrid && (!this.grid.navigation.activeNode.gridID || this.grid.navigation.activeNode.gridID !== this.gridID))) {
784+
return;
785+
}
781786
const dragMode = this.selectionService.pointerEnter(this.selectionNode, event);
782787
if (dragMode) {
783788
this.grid.cdr.detectChanges();
@@ -789,7 +794,9 @@ export class IgxGridCellComponent implements OnInit, OnChanges, OnDestroy {
789794
* @internal
790795
*/
791796
pointerup = (event: PointerEvent) => {
792-
if (!isLeftClick(event)) { return; }
797+
const isHierarchicalGrid = this.grid.nativeElement.tagName.toLowerCase() === 'igx-hierarchical-grid';
798+
if (!isLeftClick(event) || !this.grid.navigation.activeNode || (isHierarchicalGrid && (!this.grid.navigation.activeNode.gridID ||
799+
this.grid.navigation.activeNode.gridID !== this.gridID))) { return; }
793800
if (this.selectionService.pointerUp(this.selectionNode, this.grid.onRangeSelection)) {
794801
this.grid.cdr.detectChanges();
795802
}

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,10 @@ export class IgxHierarchicalGridCellComponent extends IgxGridCellComponent imple
4747
// TODO: Extend the new selection service to avoid complete traversal
4848
_clearAllHighlights() {
4949
[this._rootGrid, ...this._rootGrid.getChildGrids(true)].forEach(grid => {
50-
grid.selectionService.clear();
51-
if (grid.navigation.activeNode) {
52-
grid.navigation.activeNode.row = null;
50+
if (grid !== this.grid && grid.navigation.activeNode) {
51+
grid.navigation.clearActivation();
52+
grid.selectionService.initKeyboardState();
53+
grid.selectionService.clear();
5354
}
5455
grid.selectionService.activeElement = null;
5556
grid.nativeElement.classList.remove('igx-grid__tr--highlighted');
@@ -81,6 +82,7 @@ export class IgxHierarchicalGridCellComponent extends IgxGridCellComponent imple
8182
const parentRowID = parentGrid.hgridAPI.getParentRowId(childGrid);
8283
parentGrid.highlightedRowID = parentRowID;
8384
}
85+
this.grid.navigation.activeNode.gridID = this.gridID;
8486
super.activate(event);
8587
}
8688
}

projects/igniteui-angular/src/lib/grids/hierarchical-grid/hierarchical-grid-navigation.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
240240
const nextColumnIndex = columnIndex <= lastVisibleIndex ? columnIndex : lastVisibleIndex;
241241
this._pendingNavigation = true;
242242
const cbFunc = (args) => {
243-
args.target.grid.tbody.nativeElement.focus();
244243
this._pendingNavigation = false;
245244
cb(args);
245+
args.target.grid.tbody.nativeElement.focus();
246246
};
247247
this.grid.parent.navigation.navigateInBody(targetRowIndex, nextColumnIndex, cbFunc);
248248
}

0 commit comments

Comments
 (0)