Skip to content

Commit 988968a

Browse files
authored
Merge branch 'master' into mkirova/fix-5039-master
2 parents 07e1eae + 29e5e85 commit 988968a

File tree

2 files changed

+32
-11
lines changed

2 files changed

+32
-11
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export class IgxGridNavigationService {
131131
if (this.isColumnLeftEdgeVisible(visibleColumnIndex + 1)) {
132132
element.nextElementSibling.firstElementChild.focus({ preventScroll: true });
133133
} else {
134-
this.grid.nativeElement.focus({ preventScroll: true });
134+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
135135
this.grid.parentVirtDir.onChunkLoad
136136
.pipe(first())
137137
.subscribe(() => {
@@ -205,7 +205,7 @@ export class IgxGridNavigationService {
205205
if (this.grid.pinnedColumns.length || this.displayContainerScrollLeft === 0) {
206206
firstCell.focus({ preventScroll: true });
207207
} else {
208-
this.grid.nativeElement.focus({ preventScroll: true });
208+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
209209
this.grid.parentVirtDir.onChunkLoad
210210
.pipe(first())
211211
.subscribe(() => {
@@ -226,7 +226,7 @@ export class IgxGridNavigationService {
226226
const allCells = rowElement.querySelectorAll(this.getCellSelector(-1, isSummary));
227227
allCells[allCells.length - 1].focus({ preventScroll: true });
228228
} else {
229-
this.grid.nativeElement.focus({ preventScroll: true });
229+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
230230
this.grid.parentVirtDir.onChunkLoad
231231
.pipe(first())
232232
.subscribe(() => {
@@ -245,7 +245,7 @@ export class IgxGridNavigationService {
245245
`${cellSelector}[data-visibleIndex="${visibleColumnIndex}"]`);
246246
cells[0].focus();
247247
} else {
248-
this.grid.nativeElement.focus({ preventScroll: true });
248+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
249249
this.grid.verticalScrollContainer.scrollTo(0);
250250
this.grid.verticalScrollContainer.onChunkLoad
251251
.pipe(first()).subscribe(() => {
@@ -265,7 +265,7 @@ export class IgxGridNavigationService {
265265
`${cellSelector}[data-visibleIndex="${visibleColumnIndex}"]`);
266266
cells[cells.length - 1].focus();
267267
} else {
268-
this.grid.nativeElement.focus({ preventScroll: true });
268+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
269269
this.grid.verticalScrollContainer.scrollTo(this.grid.verticalScrollContainer.igxForOf.length - 1);
270270
this.grid.verticalScrollContainer.onChunkLoad
271271
.pipe(first()).subscribe(() => {
@@ -285,7 +285,7 @@ export class IgxGridNavigationService {
285285
const containerTopOffset = parseInt(this.verticalDisplayContainerElement.style.top, 10);
286286
if (!rowElement.previousElementSibling ||
287287
rowElement.previousElementSibling.offsetTop < Math.abs(containerTopOffset)) {
288-
this.grid.nativeElement.focus({ preventScroll: true });
288+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
289289
this.grid.verticalScrollContainer.scrollTo(currentRowIndex - 1);
290290
this.grid.verticalScrollContainer.onChunkLoad
291291
.pipe(first())
@@ -322,7 +322,7 @@ export class IgxGridNavigationService {
322322
const targetEndTopOffset = rowElement.nextElementSibling ?
323323
rowElement.nextElementSibling.offsetTop + rowHeight + parseInt(this.verticalDisplayContainerElement.style.top, 10) :
324324
containerHeight + rowHeight;
325-
this.grid.nativeElement.focus({ preventScroll: true });
325+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
326326
if (containerHeight && containerHeight < targetEndTopOffset) {
327327
const nextIndex = currentRowIndex + 1;
328328
this.grid.verticalScrollContainer.scrollTo(nextIndex);
@@ -366,7 +366,7 @@ export class IgxGridNavigationService {
366366
if (!horizontalScroll.clientWidth || parseInt(horizontalScroll.scrollLeft, 10) <= 1 || this.grid.pinnedColumns.length) {
367367
this.navigateTop(0);
368368
} else {
369-
this.grid.nativeElement.focus({ preventScroll: true });
369+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
370370
this.horizontalScroll(this.grid.dataRowList.first.index).scrollTo(0);
371371
this.grid.parentVirtDir.onChunkLoad
372372
.pipe(first())
@@ -385,7 +385,7 @@ export class IgxGridNavigationService {
385385
const rowIndex = parseInt(rows[rows.length - 1].getAttribute('data-rowIndex'), 10);
386386
this.onKeydownEnd(rowIndex);
387387
} else {
388-
this.grid.nativeElement.focus({ preventScroll: true });
388+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
389389
this.grid.verticalScrollContainer.scrollTo(this.grid.verticalScrollContainer.igxForOf.length - 1);
390390
this.grid.verticalScrollContainer.onChunkLoad
391391
.pipe(first()).subscribe(() => {
@@ -598,7 +598,7 @@ export class IgxGridNavigationService {
598598
public performHorizontalScrollToCell(
599599
rowIndex: number, visibleColumnIndex: number, isSummary: boolean = false, cb?: () => void) {
600600
const unpinnedIndex = this.getColumnUnpinnedIndex(visibleColumnIndex);
601-
this.grid.nativeElement.focus({ preventScroll: true });
601+
this.getFocusableGrid().nativeElement.focus({ preventScroll: true });
602602
this.grid.parentVirtDir.onChunkLoad
603603
.pipe(first())
604604
.subscribe(() => {
@@ -614,6 +614,10 @@ export class IgxGridNavigationService {
614614
this.horizontalScroll(rowIndex).scrollTo(unpinnedIndex);
615615
}
616616

617+
protected getFocusableGrid() {
618+
return this.grid;
619+
}
620+
617621
protected getRowByIndex(index, selector = this.getRowSelector()) {
618622
return this.grid.nativeElement.querySelector(
619623
`${selector}[data-rowindex="${index}"]`);

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { first } from 'rxjs/operators';
44
import { FilterMode } from '../grid-base.component';
55
import { IgxColumnComponent } from '../../grids/column.component';
66
import { ISelectionNode } from '../../core/grid-selection';
7+
import { isIE } from '../../core/utils';
78

89
export class IgxHierarchicalGridNavigationService extends IgxGridNavigationService {
910
public grid: IgxHierarchicalGridComponent;
@@ -174,6 +175,18 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
174175
if (cells.length > 0) { cells[cells.length - 1].focus(); }
175176
});
176177
}
178+
} else if (this.grid.parent !== null) {
179+
const childContainer = this.grid.nativeElement.parentNode.parentNode;
180+
const diff =
181+
childContainer.getBoundingClientRect().bottom - this.grid.rootGrid.tbody.nativeElement.getBoundingClientRect().bottom;
182+
const endIsVisible = diff < 0;
183+
const scrollable = this.getNextScrollableDown(this.grid);
184+
if (!endIsVisible) {
185+
this.scrollGrid(scrollable.grid, diff,
186+
() => super.navigateBottom(visibleColumnIndex));
187+
} else {
188+
super.navigateBottom(visibleColumnIndex);
189+
}
177190
} else {
178191
super.navigateBottom(visibleColumnIndex);
179192
}
@@ -423,6 +436,10 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
423436
}
424437
}
425438

439+
public getFocusableGrid() {
440+
return (isIE() && this.grid.rootGrid) ? this.grid.rootGrid : this.grid;
441+
}
442+
426443
private getLastGridElem(trContainer) {
427444
const children = trContainer.children;
428445
const closestChild = children[children.length - 1].children[0].children[0];
@@ -720,7 +737,7 @@ export class IgxHierarchicalGridNavigationService extends IgxGridNavigationServi
720737
grid.dataRowList.toArray()[0].virtDirRow.scrollTo(unpinnedIndex);
721738
}
722739
private scrollGrid(grid, target, callBackFunc) {
723-
grid.nativeElement.focus({ preventScroll: true });
740+
this.getFocusableGrid().nativeElement.focus({preventScroll: true});
724741
requestAnimationFrame(() => {
725742
if (typeof target === 'number') {
726743
grid.verticalScrollContainer.addScrollTop(target);

0 commit comments

Comments
 (0)