Skip to content

Commit 0833f39

Browse files
authored
Merge branch 'master' into rkaraivanov/remove-raf-81x
2 parents 844a67e + 2734508 commit 0833f39

File tree

4 files changed

+53
-5
lines changed

4 files changed

+53
-5
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,14 +455,17 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
455455
const cell = cells[0];
456456
const childContainer = this.grid.nativeElement.parentNode.parentNode;
457457
const scrTop = this.grid.parent.verticalScrollContainer.getVerticalScroll().scrollTop;
458+
const maxScroll = this.grid.parent.verticalScrollContainer.getVerticalScroll().scrollHeight - this.grid.parent.calcHeight;
458459
const dc = childContainer.parentNode.parentNode;
459460
const scrWith = parseInt(dc.style.top, 10);
460-
if (scrTop === 0 || scrWith === 0) {
461+
const parentRowOffset = childContainer.parentNode.offsetTop + this.grid.nativeElement.offsetTop +
462+
scrWith;
463+
if ((scrTop === 0 && parentRowOffset < 0 ) || parentRowOffset === 0 || (scrTop === maxScroll && parentRowOffset > 0)) {
461464
// cell is in view
462465
cell.focus({ preventScroll: true });
463466
} else {
464467
// scroll parent so that cell is in view
465-
this.scrollGrid(this.grid.parent, scrWith, () => cell.focus({ preventScroll: true }));
468+
this.scrollGrid(this.grid.parent, parentRowOffset, () => cell.focus({ preventScroll: true }));
466469
}
467470
}
468471

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,9 @@ export class IgxHierarchicalGridComponent extends IgxHierarchicalGridBaseCompone
672672

673673
const childGrids = this.getChildGrids(true);
674674
childGrids.forEach((grid) => {
675+
if (grid.isPercentWidth) {
676+
grid.reflow();
677+
}
675678
grid.updateScrollPosition();
676679
});
677680
}

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

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ describe('IgxHierarchicalGrid Basic Navigation', () => {
274274
expect(childCell.rowIndex).toBe(0);
275275

276276
const currScrTop = hierarchicalGrid.verticalScrollContainer.getVerticalScroll().scrollTop;
277-
expect(currScrTop).toBeLessThanOrEqual(childGrid.rowHeight + 1);
277+
const childGridOffset = childGrid.nativeElement.offsetTop;
278+
expect(currScrTop).toBeLessThanOrEqual(childGrid.rowHeight + 1 + childGridOffset);
278279
}));
279280

280281
it('should allow navigating to bottom in child grid when child grid target row moves outside the parent view port.', (async () => {
@@ -349,7 +350,29 @@ describe('IgxHierarchicalGrid Basic Navigation', () => {
349350
expect(childFirstRowCell.rowIndex).toBe(0);
350351

351352
const currScrTop = hierarchicalGrid.verticalScrollContainer.getVerticalScroll().scrollTop;
352-
expect(currScrTop).toBeLessThanOrEqual(childGrid.rowHeight + 1);
353+
const childGridOffset = childGrid.nativeElement.offsetTop;
354+
expect(currScrTop).toBeLessThanOrEqual(childGrid.rowHeight + 1 + childGridOffset);
355+
}));
356+
357+
it('should scroll top of child grid into view when pressing Ctrl + Arrow Up when cell is selected in it.', (async () => {
358+
hierarchicalGrid.verticalScrollContainer.scrollTo(3);
359+
await wait(100);
360+
fixture.detectChanges();
361+
362+
const childGrid = hierarchicalGrid.hgridAPI.getChildGrids(false)[3];
363+
const childLastRowCell = childGrid.dataRowList.toArray()[9].cells.toArray()[0];
364+
childLastRowCell.nativeElement.focus();
365+
fixture.detectChanges();
366+
childLastRowCell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowUp', ctrlKey: true }));
367+
await wait(100);
368+
fixture.detectChanges();
369+
const childFirstRowCell = childGrid.dataRowList.toArray()[0].cells.toArray()[0];
370+
expect(childFirstRowCell.selected).toBe(true);
371+
expect(childFirstRowCell.columnIndex).toBe(0);
372+
expect(childFirstRowCell.rowIndex).toBe(0);
373+
374+
const currScrTop = hierarchicalGrid.verticalScrollContainer.getVerticalScroll().scrollTop;
375+
expect(currScrTop).toBeGreaterThanOrEqual(2000);
353376
}));
354377

355378
it('when navigating down from parent into child should scroll child grid to top and start navigation from first row.', (async () => {

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,24 @@ describe('Basic IgxHierarchicalGrid', () => {
268268
expect(hierarchicalGrid.nativeElement.classList.contains('igx-grid--compact')).toBe(true);
269269
expect(childGrid.displayDensity).toBe(DisplayDensity.compact);
270270
}));
271+
272+
it('when child width is in percents its width should be update if parent width changes while parent row is collapsed. ', async () => {
273+
const row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
274+
UIInteractions.clickElement(row.expander);
275+
fixture.detectChanges();
276+
const childGrids = fixture.debugElement.queryAll(By.css('igx-child-grid-row'));
277+
const childGrid = childGrids[0].query(By.css('igx-hierarchical-grid')).componentInstance;
278+
expect(childGrid.calcWidth - 370).toBeLessThan(3);
279+
UIInteractions.clickElement(row.expander);
280+
fixture.detectChanges();
281+
fixture.componentInstance.width = '300px';
282+
fixture.detectChanges();
283+
await wait(30);
284+
fixture.detectChanges();
285+
UIInteractions.clickElement(row.expander);
286+
fixture.detectChanges();
287+
expect(childGrid.calcWidth - 170).toBeLessThan(3);
288+
});
271289
});
272290

273291
describe('IgxHierarchicalGrid Row Islands', () => {
@@ -944,7 +962,7 @@ describe('IgxHierarchicalGrid Runtime Row Island change Scenarios', () => {
944962
@Component({
945963
template: `
946964
<igx-hierarchical-grid #grid1 [data]="data"
947-
[autoGenerate]="false" [height]="'400px'" [width]="'500px'" #hierarchicalGrid>
965+
[autoGenerate]="false" [height]="'400px'" [width]="width" #hierarchicalGrid>
948966
<igx-column field="ID"></igx-column>
949967
<igx-column field="ProductName"></igx-column>
950968
<igx-row-island [key]="'childData'" [autoGenerate]="false" #rowIsland>
@@ -960,6 +978,7 @@ describe('IgxHierarchicalGrid Runtime Row Island change Scenarios', () => {
960978
})
961979
export class IgxHierarchicalGridTestBaseComponent {
962980
public data;
981+
public width = '500px';
963982
@ViewChild('hierarchicalGrid', { read: IgxHierarchicalGridComponent, static: true }) public hgrid: IgxHierarchicalGridComponent;
964983
@ViewChild('rowIsland', { read: IgxRowIslandComponent, static: true }) public rowIsland: IgxRowIslandComponent;
965984
@ViewChild('rowIsland2', { read: IgxRowIslandComponent, static: true }) public rowIsland2: IgxRowIslandComponent;

0 commit comments

Comments
 (0)