Skip to content

Commit be3947b

Browse files
authored
Merge branch 'master' into mdragnev/add-row-tests
2 parents 62b7b65 + 0778d81 commit be3947b

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4096,7 +4096,13 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
40964096
};
40974097
this.verticalScrollContainer.onDataChanged.pipe(first()).subscribe(() => {
40984098
this.cdr.detectChanges();
4099-
const row = this.getRowByIndex(this.addRowParent.index + 1);
4099+
const newRowIndex = this.addRowParent.index + 1;
4100+
// ensure adding row is in view.
4101+
const shouldScroll = this.navigation.shouldPerformVerticalScroll(newRowIndex, -1);
4102+
if (shouldScroll) {
4103+
this.navigateTo(newRowIndex, -1);
4104+
}
4105+
const row = this.getRowByIndex(newRowIndex);
41004106
const cell = row.cells.find(c => c.editable);
41014107
cell.setEditMode(true);
41024108
cell.activate();

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
44
import { IgxHierarchicalGridModule } from './public_api';
55
import { Component, ViewChild, DebugElement} from '@angular/core';
66
import { IgxHierarchicalGridComponent } from './hierarchical-grid.component';
7-
import { wait, UIInteractions } from '../../test-utils/ui-interactions.spec';
7+
import { wait, UIInteractions, waitForSelectionChange, waitForGridScroll } from '../../test-utils/ui-interactions.spec';
88
import { IgxRowIslandComponent } from './row-island.component';
99
import { By } from '@angular/platform-browser';
1010
import { IgxHierarchicalRowComponent } from './hierarchical-row.component';
@@ -193,7 +193,8 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
193193
const childGridContent = fixture.debugElement.queryAll(By.css(GRID_CONTENT_CLASS))[1];
194194
UIInteractions.triggerEventHandlerKeyDown('arrowdown', childGridContent, false, false, true);
195195
fixture.detectChanges();
196-
await wait(1000);
196+
// wait for parent grid to complete scroll to child cell.
197+
await waitForGridScroll(hierarchicalGrid);
197198
fixture.detectChanges();
198199

199200
const selectedCell = fixture.componentInstance.selectedCell;
@@ -368,7 +369,7 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
368369

369370
UIInteractions.triggerEventHandlerKeyDown('end', baseHGridContent, false, false, true);
370371
fixture.detectChanges();
371-
await wait(1000);
372+
await waitForSelectionChange(hierarchicalGrid);
372373
fixture.detectChanges();
373374

374375
const lastDataCell = hierarchicalGrid.getCellByKey(19, 'childData2');

projects/igniteui-angular/src/lib/test-utils/ui-interactions.spec.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,18 @@ export function wait(ms = 0) {
66
return new Promise((resolve, reject) => setTimeout(resolve, ms));
77
}
88

9-
export function waitForActiveNodeChange (grid) {
9+
export function waitForGridScroll(grid) {
1010
// wait for grid scroll operation to complete and state to be updated.
11+
return new Promise((resolve, reject) => {
12+
grid.onScroll.pipe(first()).subscribe(() => {
13+
grid.cdr.detectChanges();
14+
resolve();
15+
});
16+
});
17+
}
18+
19+
export function waitForActiveNodeChange (grid) {
20+
// wait for grid activation operation to complete and state to be updated.
1121
return new Promise((resolve, reject) => {
1222
grid.activeNodeChange.pipe(first()).subscribe(() => {
1323
grid.cdr.detectChanges();
@@ -17,7 +27,7 @@ export function waitForActiveNodeChange (grid) {
1727
}
1828

1929
export function waitForSelectionChange (grid) {
20-
// wait for grid scroll operation to complete and state to be updated.
30+
// wait for grid selection operation to complete and state to be updated.
2131
return new Promise((resolve, reject) => {
2232
grid.onSelection.pipe(first()).subscribe(() => {
2333
grid.cdr.detectChanges();

0 commit comments

Comments
 (0)