Skip to content

Commit b0173b1

Browse files
authored
fix(hgrid): remerge cells after activation clears - 20.1.x (#16812)
1 parent 5114e65 commit b0173b1

2 files changed

Lines changed: 65 additions & 1 deletion

File tree

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

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ByLevelTreeGridMergeStrategy, DefaultMergeStrategy, DefaultSortingStrat
55
import { DataParent } from '../../test-utils/sample-test-data.spec';
66
import { GridFunctions, GridSelectionFunctions } from '../../test-utils/grid-functions.spec';
77
import { By } from '@angular/platform-browser';
8-
import { UIInteractions, wait } from '../../test-utils/ui-interactions.spec';
8+
import { UIInteractions, wait, waitForActiveNodeChange } from '../../test-utils/ui-interactions.spec';
99
import { hasClass, setElementSize } from '../../test-utils/helper-utils.spec';
1010
import { ColumnLayoutTestComponent } from './grid.multi-row-layout.spec';
1111
import { IgxHierarchicalGridTestBaseComponent } from '../hierarchical-grid/hierarchical-grid.spec';
@@ -1105,6 +1105,68 @@ describe('IgxGrid - Cell merging #grid', () => {
11051105
]);
11061106
});
11071107

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

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

projects/igniteui-angular/src/lib/grids/hierarchical-grid/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)