Skip to content

Commit 6c9b8e1

Browse files
Merge branch '8.1.x' into astaev/issue5627-8.1.x
2 parents cdd6644 + 62346a0 commit 6c9b8e1

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
@@ -5072,16 +5072,16 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
50725072
if (this.verticalScrollContainer.igxForOf.slice(rowIndex, rowIndex + 1).find(rec => rec.expression || rec.childGridsData)) {
50735073
visibleColIndex = -1;
50745074
}
5075-
if (visibleColIndex === -1 || this.navigation.isColumnFullyVisible(visibleColIndex)) {
5076-
if (this.navigation.shouldPerformVerticalScroll(rowIndex, visibleColIndex)) {
5077-
this.navigation.performVerticalScrollToCell(rowIndex, visibleColIndex,
5078-
() => { this.executeCallback(rowIndex, visibleColIndex, cb); });
5079-
} else {
5080-
this.executeCallback(rowIndex, visibleColIndex, cb);
5081-
}
5082-
} else {
5075+
const shouldScrollVertically = this.navigation.shouldPerformVerticalScroll(rowIndex, visibleColIndex);
5076+
const shouldScrollHorizontally = visibleColIndex !== -1 && !this.navigation.isColumnFullyVisible(visibleColIndex);
5077+
if (shouldScrollVertically) {
5078+
this.navigation.performVerticalScrollToCell(rowIndex, visibleColIndex,
5079+
() => { this.navigateTo(rowIndex, visibleColIndex, cb); });
5080+
} else if (shouldScrollHorizontally) {
50835081
this.navigation.performHorizontalScrollToCell(rowIndex, visibleColIndex, false,
5084-
() => { this.executeCallback(rowIndex, visibleColIndex, cb); });
5082+
() => { this.navigateTo(rowIndex, visibleColIndex, cb); });
5083+
} else {
5084+
this.executeCallback(rowIndex, visibleColIndex, cb);
50855085
}
50865086
}
50875087

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
@@ -844,6 +844,23 @@ describe('IgxGrid - Keyboard navigation', () => {
844844
expect(target.focused).toBe(true);
845845
});
846846

847+
it('Custom KB navigation: should be able to scroll horizontally and vertically to a cell in the grid', async () => {
848+
fix.componentInstance.columns = fix.componentInstance.generateCols(100);
849+
fix.componentInstance.data = fix.componentInstance.generateData(100);
850+
851+
fix.detectChanges();
852+
853+
grid.navigateTo(50, 50, (args) => { args.target.nativeElement.focus(); });
854+
await wait(DEBOUNCETIME);
855+
fix.detectChanges();
856+
await wait(DEBOUNCETIME);
857+
fix.detectChanges();
858+
859+
const target = grid.getCellByColumn(50, '50');
860+
expect(target).toBeDefined();
861+
expect(target.focused).toBe(true);
862+
});
863+
847864
it('Custom KB navigation: onGridKeydown should be emitted', async () => {
848865
fix.componentInstance.columns = fix.componentInstance.generateCols(25);
849866
fix.componentInstance.data = fix.componentInstance.generateData(25);

0 commit comments

Comments
 (0)