Skip to content

Commit 7c97928

Browse files
authored
Merge pull request #5979 from IgniteUI/mkirova/fix-5889-8.2.x
Fix navigateTo so that it works when passing both row and column index.
2 parents 1cb2b97 + 1ee8be4 commit 7c97928

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5307,16 +5307,16 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
53075307
if (this.dataView.slice(rowIndex, rowIndex + 1).find(rec => rec.expression || rec.childGridsData)) {
53085308
visibleColIndex = -1;
53095309
}
5310-
if (visibleColIndex === -1 || this.navigation.isColumnFullyVisible(visibleColIndex)) {
5311-
if (this.navigation.shouldPerformVerticalScroll(rowIndex, visibleColIndex)) {
5312-
this.navigation.performVerticalScrollToCell(rowIndex, visibleColIndex,
5313-
() => { this.executeCallback(rowIndex, visibleColIndex, cb); });
5314-
} else {
5315-
this.executeCallback(rowIndex, visibleColIndex, cb);
5316-
}
5317-
} else {
5310+
const shouldScrollVertically = this.navigation.shouldPerformVerticalScroll(rowIndex, visibleColIndex);
5311+
const shouldScrollHorizontally = visibleColIndex !== -1 && !this.navigation.isColumnFullyVisible(visibleColIndex);
5312+
if (shouldScrollVertically) {
5313+
this.navigation.performVerticalScrollToCell(rowIndex, visibleColIndex,
5314+
() => { this.navigateTo(rowIndex, visibleColIndex, cb); });
5315+
} else if (shouldScrollHorizontally) {
53185316
this.navigation.performHorizontalScrollToCell(rowIndex, visibleColIndex, false,
5319-
() => { this.executeCallback(rowIndex, visibleColIndex, cb); });
5317+
() => { this.navigateTo(rowIndex, visibleColIndex, cb); });
5318+
} else {
5319+
this.executeCallback(rowIndex, visibleColIndex, cb);
53205320
}
53215321
}
53225322

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,23 @@ describe('IgxGrid - Keyboard navigation #grid', () => {
856856
expect(target.focused).toBe(true);
857857
});
858858

859+
it('Custom KB navigation: should be able to scroll horizontally and vertically to a cell in the grid', async () => {
860+
fix.componentInstance.columns = fix.componentInstance.generateCols(100);
861+
fix.componentInstance.data = fix.componentInstance.generateData(100);
862+
863+
fix.detectChanges();
864+
865+
grid.navigateTo(50, 50, (args) => { args.target.nativeElement.focus(); });
866+
await wait(DEBOUNCETIME);
867+
fix.detectChanges();
868+
await wait(DEBOUNCETIME);
869+
fix.detectChanges();
870+
871+
const target = grid.getCellByColumn(50, '50');
872+
expect(target).toBeDefined();
873+
expect(target.focused).toBe(true);
874+
});
875+
859876
it('Custom KB navigation: onGridKeydown should be emitted', async () => {
860877
fix.componentInstance.columns = fix.componentInstance.generateCols(25);
861878
fix.detectChanges();

0 commit comments

Comments
 (0)