Skip to content

Commit aca57ee

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Adjust for scenarios after horizontal nav into merged cell.
1 parent 4d1b981 commit aca57ee

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ export class IgxGridMergeNavigationService extends IgxGridNavigationService {
4848
}
4949

5050
protected override getNextPosition(rowIndex: number, colIndex: number, key: string, shift: boolean, ctrl: boolean, event: KeyboardEvent) {
51-
5251
const field = this.grid.visibleColumns[colIndex]?.field;
52+
const currentRec = this.grid.verticalScrollContainer.igxForOf[this.activeNode.row];
53+
const currentRootRec = currentRec?.cellMergeMeta?.get(field)?.root;
54+
const currentIndex = currentRootRec ? this.grid.verticalScrollContainer.igxForOf.indexOf(currentRootRec) : this.activeNode.row;
5355
switch (key) {
5456
case 'tab':
5557
case ' ':
@@ -76,16 +78,15 @@ export class IgxGridMergeNavigationService extends IgxGridNavigationService {
7678
break;
7779
case 'arrowup':
7880
case 'up':
79-
const prevRec = this.grid.verticalScrollContainer.igxForOf[this.activeNode.row - 1];
80-
const root = prevRec?.cellMergeMeta?.get(field)?.root;
81-
const prev = this.activeNode.row - (root?.cellMergeMeta?.get(field).rowSpan || 1);
81+
const prevRec = this.grid.verticalScrollContainer.igxForOf[currentIndex - 1];
82+
const prevRoot = prevRec?.cellMergeMeta?.get(field)?.root;
83+
const prev = currentIndex - (prevRoot?.cellMergeMeta?.get(field).rowSpan || 1);
8284
colIndex = this.activeNode.column !== undefined ? this.activeNode.column : 0;
8385
rowIndex = ctrl ? this.findFirstDataRowIndex() : prev;
8486
break;
8587
case 'arrowdown':
8688
case 'down':
87-
const rec = this.grid.verticalScrollContainer.igxForOf[this.activeNode.row];
88-
const next = this.activeNode.row + (rec?.cellMergeMeta?.get(field)?.rowSpan || 1);
89+
const next = currentIndex + ((currentRootRec || currentRec)?.cellMergeMeta?.get(field)?.rowSpan || 1);
8990
colIndex = this.activeNode.column !== undefined ? this.activeNode.column : 0;
9091
rowIndex = ctrl ? this.findLastDataRowIndex() : next;
9192
break;

0 commit comments

Comments
 (0)