Skip to content

Commit 5ac407d

Browse files
authored
Merge pull request #15010 from IgniteUI/dkamburov/fix-flicker-scroll-hgrid
test(hgrid): fix flicker for scrolling inside hierarchical grid
2 parents 5259fef + 4b1c9ef commit 5ac407d

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

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

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { GridFunctions } from '../../test-utils/grid-functions.spec';
1515
import { HierarchicalGridFunctions } from '../../test-utils/hierarchical-grid-functions.spec';
1616
import { IgxHierarchicalRowComponent } from './hierarchical-row.component';
1717
import { IgxHierarchicalGridDefaultComponent } from '../../test-utils/hierarchical-grid-components.spec';
18+
import { firstValueFrom } from 'rxjs';
1819

1920
describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
2021
let fixture;
@@ -101,7 +102,7 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
101102
fixture.detectChanges();
102103

103104
const childGrid = hierarchicalGrid.gridAPI.getChildGrids(false)[0] as IgxHierarchicalGridComponent;
104-
const childCell = childGrid.gridAPI.get_cell_by_index(0, 'ID');
105+
const childCell = childGrid.gridAPI.get_cell_by_index(0, 'ID');
105106
GridFunctions.focusCell(fixture, childCell);
106107
fixture.detectChanges();
107108

@@ -169,7 +170,7 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
169170
await wait(100);
170171
fixture.detectChanges();
171172
const startIndex = hierarchicalGrid.verticalScrollContainer.state.startIndex;
172-
const topOffset = GridFunctions.getGridDisplayContainer(fixture).nativeElement.style.top;
173+
const topOffset = GridFunctions.getGridDisplayContainer(fixture).nativeElement.style.top;
173174
const secondRow = hierarchicalGrid.dataRowList.toArray()[1];
174175
// expand second row
175176
(secondRow.nativeElement.children[0] as HTMLElement).click();
@@ -194,6 +195,7 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
194195
});
195196

196197
it('should not lose scroll position after expanding a row when there are already expanded rows above.', async () => {
198+
197199
// Expand two rows at the top
198200
(hierarchicalGrid.dataRowList.toArray()[2].nativeElement.children[0] as HTMLElement).click();
199201
await wait();
@@ -205,7 +207,7 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
205207

206208
// Scroll to bottom
207209
hierarchicalGrid.verticalScrollContainer.getScroll().scrollTop = 5000;
208-
await wait(50);
210+
await firstValueFrom(hierarchicalGrid.verticalScrollContainer.chunkLoad);
209211
fixture.detectChanges();
210212
// Expand two rows at the bottom
211213
(hierarchicalGrid.dataRowList.toArray()[6].nativeElement.children[0] as HTMLElement).click();
@@ -218,12 +220,12 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
218220

219221
// Scroll to top to make sure top.
220222
hierarchicalGrid.verticalScrollContainer.getScroll().scrollTop = 0;
221-
await wait();
223+
await firstValueFrom(hierarchicalGrid.verticalScrollContainer.chunkLoad);
222224
fixture.detectChanges();
223225

224226
// Scroll to somewhere in the middle and make sure scroll position stays when expanding/collapsing.
225227
hierarchicalGrid.verticalScrollContainer.getScroll().scrollTop = 1250;
226-
await wait();
228+
await firstValueFrom(hierarchicalGrid.verticalScrollContainer.chunkLoad);
227229
fixture.detectChanges();
228230
const startIndex = hierarchicalGrid.verticalScrollContainer.state.startIndex;
229231
const topOffset = GridFunctions.getGridDisplayContainer(fixture).nativeElement.style.top;
@@ -266,7 +268,7 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
266268
hierarchicalGrid.verticalScrollContainer.state.chunkSize).toBe(80);
267269
expect(hierarchicalGrid.verticalScrollContainer.getScroll().scrollTop)
268270
.toEqual(hierarchicalGrid.verticalScrollContainer.getScroll().scrollHeight -
269-
parseInt(hierarchicalGrid.verticalScrollContainer.igxForContainerSize, 10));
271+
parseInt(hierarchicalGrid.verticalScrollContainer.igxForContainerSize, 10));
270272
});
271273

272274
it('should update scroll height after expanding/collapsing rows.', async () => {
@@ -326,7 +328,7 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
326328
expect(scrHeight).toBe(3 * 51 + (childGrid1.nativeElement.closest('.igx-grid__tr-container') as HTMLElement).offsetHeight - 1);
327329
});
328330

329-
it('should update context information correctly for child grid container after scrolling', async () => {
331+
it('should update context information correctly for child grid container after scrolling', async () => {
330332
// expand 3rd row
331333
const row = hierarchicalGrid.dataRowList.toArray()[3];
332334
(row.nativeElement.children[0] as HTMLElement).click();
@@ -345,7 +347,7 @@ describe('IgxHierarchicalGrid Virtualization #hGrid', () => {
345347
expect(childRowComponent.index).toBe(4);
346348
});
347349

348-
it('should update scrollbar when expanding a row with data loaded after initial view initialization', (done) => {
350+
it('should update scrollbar when expanding a row with data loaded after initial view initialization', (done) => {
349351
fixture.componentInstance.data = fixture.componentInstance.generateData(10, 0);
350352
fixture.detectChanges();
351353

@@ -446,7 +448,7 @@ describe('IgxHierarchicalGrid Virtualization Custom Scenarios #hGrid', () => {
446448
});
447449
}));
448450

449-
it('should show scrollbar after expanding a row with data loaded after initial view initialization', async () => {
451+
it('should show scrollbar after expanding a row with data loaded after initial view initialization', async () => {
450452
const fixture = TestBed.createComponent(IgxHierarchicalGridNoScrollTestComponent);
451453
fixture.detectChanges();
452454
await wait();
@@ -505,12 +507,13 @@ export class IgxHierarchicalGridTestBaseComponent {
505507
let children;
506508
for (let i = 0; i < count; i++) {
507509
const rowID = parendID ? parendID + i : i.toString();
508-
if (level > 0 ) {
509-
children = this.generateData(count / 2 , currLevel - 1, rowID);
510-
}
511-
prods.push({
512-
ID: rowID, ChildLevels: currLevel, ProductName: 'Product: A' + i, Col1: i,
513-
Col2: i, Col3: i, childData: children, childData2: children });
510+
if (level > 0) {
511+
children = this.generateData(count / 2, currLevel - 1, rowID);
512+
}
513+
prods.push({
514+
ID: rowID, ChildLevels: currLevel, ProductName: 'Product: A' + i, Col1: i,
515+
Col2: i, Col3: i, childData: children, childData2: children
516+
});
514517
}
515518
return prods;
516519
}

0 commit comments

Comments
 (0)