Skip to content

Commit 2b99198

Browse files
authored
fix(hgrid): remerge cells after activation clears - 21.1.x (#16995)
1 parent f6cb6a9 commit 2b99198

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

projects/igniteui-angular/grids/grid/src/cell-merge.spec.ts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IgxPaginatorComponent } from 'igniteui-angular/paginator';;
66
import { DataParent } from '../../../test-utils/sample-test-data.spec';
77
import { GridFunctions, GridSelectionFunctions } from '../../../test-utils/grid-functions.spec';
88
import { By } from '@angular/platform-browser';
9-
import { UIInteractions, wait } from '../../../test-utils/ui-interactions.spec';
9+
import { UIInteractions, wait, waitForActiveNodeChange } from '../../../test-utils/ui-interactions.spec';
1010
import { hasClass, setElementSize } from '../../../test-utils/helper-utils.spec';
1111
import { ColumnLayoutTestComponent } from './grid.multi-row-layout.spec';
1212
import { IgxHierarchicalGridTestBaseComponent } from '../../hierarchical-grid/src/hierarchical-grid.spec';
@@ -1113,6 +1113,68 @@ describe('IgxGrid - Cell merging #grid', () => {
11131113
]);
11141114
});
11151115

1116+
it('should remerge child grid cells when focus moves to parent grid.', async () => {
1117+
const ri = fix.componentInstance.rowIsland;
1118+
ri.cellMergeMode = 'always';
1119+
ri.getColumnByName('ProductName').merge = true;
1120+
fix.detectChanges();
1121+
1122+
const firstRow = grid.gridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
1123+
firstRow.toggle();
1124+
fix.detectChanges();
1125+
1126+
const childGrid = grid.gridAPI.getChildGrids(false)[0] as IgxHierarchicalGridComponent;
1127+
expect(childGrid).toBeDefined();
1128+
1129+
const childCol = childGrid.getColumnByName('ProductName');
1130+
GridFunctions.verifyColumnMergedState(childGrid, childCol, [
1131+
{ value: 'Product A', span: 2 },
1132+
{ value: 'Product B', span: 1 },
1133+
{ value: 'Product A', span: 1 }
1134+
]);
1135+
1136+
await wait(1);
1137+
fix.detectChanges();
1138+
1139+
const allGrids = fix.debugElement.queryAll(By.directive(IgxHierarchicalGridComponent));
1140+
const childGridDE = allGrids.find(x => x.componentInstance === childGrid);
1141+
expect(childGridDE).toBeDefined();
1142+
const childRows = childGridDE.queryAll(By.css(CSS_CLASS_GRID_ROW));
1143+
childRows.shift();
1144+
const childRowDE = childRows[0];
1145+
const childCells = childRowDE.queryAll(By.css('.igx-grid__td'));
1146+
const childCellDE = childCells[1];
1147+
UIInteractions.simulateClickAndSelectEvent(childCellDE.nativeElement);
1148+
await wait(1);
1149+
fix.detectChanges();
1150+
1151+
GridFunctions.verifyColumnMergedState(childGrid, childCol, [
1152+
{ value: 'Product A', span: 1 },
1153+
{ value: 'Product A', span: 1 },
1154+
{ value: 'Product B', span: 1 },
1155+
{ value: 'Product A', span: 1 }
1156+
]);
1157+
1158+
const rootGridDE = allGrids.find(x => x.componentInstance === grid);
1159+
expect(rootGridDE).toBeDefined();
1160+
const parentRows = rootGridDE.queryAll(By.css(CSS_CLASS_GRID_ROW));
1161+
parentRows.shift();
1162+
const parentRowDE = parentRows[0];
1163+
const parentCells = parentRowDE.queryAll(By.css('.igx-grid__td'));
1164+
const parentCellDE = parentCells[1];
1165+
const activeChange = waitForActiveNodeChange(childGrid);
1166+
UIInteractions.simulateClickAndSelectEvent(parentCellDE.nativeElement);
1167+
await activeChange;
1168+
await wait(20);
1169+
fix.detectChanges();
1170+
1171+
GridFunctions.verifyColumnMergedState(childGrid, childCol, [
1172+
{ value: 'Product A', span: 2 },
1173+
{ value: 'Product B', span: 1 },
1174+
{ value: 'Product A', span: 1 }
1175+
]);
1176+
});
1177+
11161178
});
11171179

11181180
describe('TreeGrid', () => {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
365365
if (this.activeNode && Object.keys(this.activeNode).length) {
366366
this.activeNode = Object.assign({} as IActiveNode);
367367
}
368+
369+
this.grid.activeNodeChange.emit();
368370
}
369371

370372
private hasNextTarget(grid: GridType, index: number, isNext: boolean) {

0 commit comments

Comments
 (0)