Skip to content

Commit 0ccdecb

Browse files
committed
Merge branch 'nalipiev/ng-update-9.0.0' of https://github.com/IgniteUI/igniteui-angular into nalipiev/ng-update-9.0.0
2 parents 917b124 + b7a2f17 commit 0ccdecb

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

projects/igniteui-angular/src/lib/grids/api.service.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import { IgxCell, IgxRow } from './selection/selection.service';
1414
import { GridType } from './common/grid.interface';
1515
import { ColumnType } from './common/column.interface';
1616
import { IRowToggleEventArgs } from './common/events';
17+
import {
18+
ROW_COLLAPSE_KEYS, ROW_EXPAND_KEYS
19+
} from '../core/utils';
20+
import { first, debounceTime } from 'rxjs/operators';
1721
/**
1822
*@hidden
1923
*/
@@ -578,6 +582,12 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
578582
if (grid.rowEditable) {
579583
grid.endEdit(true);
580584
}
585+
const eventKey = event && (event as any).key ? (event as any).key.toLowerCase() : null;
586+
if (eventKey && this.isToggleKey(eventKey)) {
587+
(this.grid as any).zone.onStable.pipe(debounceTime(30)).pipe(first()).subscribe(() => {
588+
this.focusActiveCell(rowID);
589+
});
590+
}
581591
}
582592

583593
public get_rec_by_id(rowID) {
@@ -588,4 +598,20 @@ export class GridBaseAPIService <T extends IgxGridBaseDirective & GridType> {
588598
return this.grid.expansionStates.get(rowID) !== expanded;
589599
}
590600

601+
private isToggleKey(key: string): boolean {
602+
return ROW_COLLAPSE_KEYS.has(key) || ROW_EXPAND_KEYS.has(key);
603+
}
604+
605+
private focusActiveCell(rowID) {
606+
// persist focused cell
607+
const isVirtualized = !this.grid.verticalScrollContainer.dc.instance.notVirtual;
608+
const el = this.grid.selectionService.activeElement;
609+
if (isVirtualized && el) {
610+
const cell = this.get_cell_by_key(rowID, this.grid.visibleColumns[el.column].field);
611+
if (cell) {
612+
cell.nativeElement.focus();
613+
}
614+
}
615+
}
616+
591617
}

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,7 +3400,6 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
34003400
this.expansionStatesChange.emit(this._expansionStates);
34013401
if (this.gridAPI.grid) {
34023402
this.cdr.detectChanges();
3403-
this._focusActiveCell();
34043403
}
34053404
}
34063405

@@ -6257,16 +6256,4 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
62576256
advancedFilteringDialog.closeDialog();
62586257
}
62596258
}
6260-
6261-
protected _focusActiveCell() {
6262-
// persist focused cell
6263-
const isVirtualized = !this.verticalScrollContainer.dc.instance.notVirtual;
6264-
const el = this.selectionService.activeElement;
6265-
if (isVirtualized && el) {
6266-
const cell = this.gridAPI.get_cell_by_visible_index(el.row, el.column);
6267-
if (cell) {
6268-
cell.nativeElement.focus();
6269-
}
6270-
}
6271-
}
62726259
}

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,15 @@ export class IgxHierarchicalGridCellComponent extends IgxGridCellComponent imple
9393
dispatchEvent(event: KeyboardEvent) {
9494
const key = event.key.toLowerCase();
9595
if (event.altKey && !this.row.added) {
96-
const grid = this.gridAPI.grid;
9796
const collapse = this.row.expanded && (key === 'left' || key === 'arrowleft' || key === 'up' || key === 'arrowup');
9897
const expand = !this.row.expanded && (key === 'right' || key === 'arrowright' || key === 'down' || key === 'arrowdown');
9998
if (collapse) {
10099
this.gridAPI.set_row_expansion_state(this.row.rowID, false, event);
101100
} else if (expand) {
102101
this.gridAPI.set_row_expansion_state(this.row.rowID, true, event);
103102
}
104-
if (expand || collapse) {
105-
const rowID = this.cellID.rowID;
106-
grid.cdr.detectChanges();
107-
this.persistFocusedCell(rowID);
108-
}
109103
return;
110104
}
111105
super.dispatchEvent(event);
112106
}
113-
114-
protected persistFocusedCell(rowID) {
115-
requestAnimationFrame(() => {
116-
// TODO: Test it out
117-
const cell = this.gridAPI.get_cell_by_key(rowID, this.column.field);
118-
if (cell) {
119-
cell.nativeElement.focus();
120-
}
121-
});
122-
}
123107
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,13 +561,15 @@ describe('IgxHierarchicalGrid Basic Navigation #hGrid', () => {
561561
fixture.detectChanges();
562562
// collapse
563563
parentCell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft', altKey: true }));
564+
fixture.detectChanges();
564565
await wait(100);
565566
fixture.detectChanges();
566567
parentCell = hierarchicalGrid.getCellByColumn(38, 'ID');
567568
expect(parentCell.focused).toBeTruthy();
568569

569570
// expand
570571
parentCell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', altKey: true }));
572+
fixture.detectChanges();
571573
await wait(100);
572574
fixture.detectChanges();
573575
parentCell = hierarchicalGrid.getCellByColumn(38, 'ID');

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
408408
TreeGridFunctions.verifyTreeGridCellSelected(treeGrid, cell);
409409

410410
cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft', altKey: true }));
411-
await wait(DEBOUNCETIME);
411+
await wait(DEBOUNCETIME * 2);
412412
fix.detectChanges();
413413

414414
rows = TreeGridFunctions.getAllRows(fix);
@@ -427,7 +427,7 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
427427

428428
cell = treeGrid.getCellByColumn(0, 'ID');
429429
cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', altKey: true }));
430-
await wait(DEBOUNCETIME);
430+
await wait(DEBOUNCETIME * 2);
431431
fix.detectChanges();
432432

433433
rows = TreeGridFunctions.getAllRows(fix);
@@ -448,7 +448,7 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
448448
// Go to the last parent row and expand collapse
449449
cell = treeGrid.getCellByColumn(0, 'ID');
450450
cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowDown', ctrlKey: true }));
451-
await wait(2 * DEBOUNCETIME);
451+
await wait(DEBOUNCETIME * 2);
452452
fix.detectChanges();
453453

454454
cell = treeGrid.getCellByColumn(9, 'ID');
@@ -458,7 +458,7 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
458458
cell = treeGrid.getCellByColumn(8, 'ID');
459459

460460
cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowLeft', altKey: true }));
461-
await wait(DEBOUNCETIME);
461+
await wait(DEBOUNCETIME * 2);
462462
fix.detectChanges();
463463

464464
cell = treeGrid.getCellByColumn(8, 'ID');
@@ -475,7 +475,7 @@ describe('IgxTreeGrid - Key Board Navigation #tGrid', () => {
475475
cell = treeGrid.getCellByColumn(8, 'ID');
476476

477477
cell.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'ArrowRight', altKey: true }));
478-
await wait(DEBOUNCETIME);
478+
await wait(DEBOUNCETIME * 2);
479479
fix.detectChanges();
480480

481481
cell = treeGrid.getCellByColumn(8, 'ID');

0 commit comments

Comments
 (0)