Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions projects/igniteui-angular/src/lib/grids/grid-navigation.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { first } from 'rxjs/operators';
import { first, throttleTime } from 'rxjs/operators';
import { IgxForOfDirective } from '../directives/for-of/for_of.directive';
import { GridType } from './common/grid.interface';
import {
Expand All @@ -17,6 +17,7 @@ import { IActiveNodeChangeEventArgs } from './common/events';
import { IgxGridGroupByRowComponent } from './grid/groupby-row.component';
import { IMultiRowLayoutNode } from './common/types';
import { SortingDirection } from '../data-operations/sorting-strategy';
import { animationFrameScheduler, Subject } from 'rxjs';
export interface ColumnGroupsCache {
level: number;
visibleIndex: number;
Expand All @@ -37,6 +38,7 @@ export class IgxGridNavigationService {
public _activeNode: IActiveNode = {} as IActiveNode;
public lastActiveNode: IActiveNode = {} as IActiveNode;
protected pendingNavigation = false;
protected keydownNotify = new Subject<KeyboardEvent>();

public get activeNode() {
return this._activeNode;
Expand All @@ -46,7 +48,15 @@ export class IgxGridNavigationService {
this._activeNode = value;
}

constructor(protected platform: PlatformUtil) { }
constructor(protected platform: PlatformUtil) {
this.keydownNotify.pipe(
throttleTime(30, animationFrameScheduler),
)
.subscribe((event: KeyboardEvent) => {
this.dispatchEvent(event);
});

}

public handleNavigation(event: KeyboardEvent) {
const key = event.key.toLowerCase();
Expand All @@ -60,7 +70,7 @@ export class IgxGridNavigationService {
event.preventDefault();
}
if (event.repeat) {
setTimeout(() => this.dispatchEvent(event), 1);
this.keydownNotify.next(event);
} else {
this.dispatchEvent(event);
}
Expand Down Expand Up @@ -96,10 +106,8 @@ export class IgxGridNavigationService {
event.preventDefault();
this.navigateInBody(position.rowIndex, position.colIndex, (obj) => {
obj.target.activate(event);
this.grid.cdr.detectChanges();
});
}
this.grid.cdr.detectChanges();
}

public summaryNav(event: KeyboardEvent) {
Expand Down Expand Up @@ -145,7 +153,6 @@ export class IgxGridNavigationService {
this.grid.clearCellSelection();
this.grid.navigateTo(this.activeNode.row, this.activeNode.column, (obj) => {
obj.target?.activate(event);
this.grid.cdr.detectChanges();
});
} else {
if (hasLastActiveNode && !this.grid.selectionService.selected(this.lastActiveNode)) {
Expand Down Expand Up @@ -598,7 +605,6 @@ export class IgxGridNavigationService {

this.navigateInBody(next.rowIndex, next.visibleColumnIndex, (obj) => {
obj.target.activate(event);
this.grid.cdr.detectChanges();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ describe('IgxGrid - Row Editing #grid', () => {
// let cellDebug;
UIInteractions.simulateDoubleClickAndSelectEvent(cellElem);
fix.detectChanges();
await wait(DEBOUNCETIME);
fix.detectChanges();

UIInteractions.triggerEventHandlerKeyDown('tab', gridContent, false, true);
await wait(DEBOUNCETIME);
Expand Down Expand Up @@ -977,11 +979,11 @@ describe('IgxGrid - Row Editing #grid', () => {
fix.detectChanges();

const keyDonwSpy = spyOn(grid.gridKeydown, 'emit');
const detectChangesSpy = spyOn(grid.cdr, 'detectChanges').and.callThrough();

UIInteractions.simulateDoubleClickAndSelectEvent(targetCell);
fix.detectChanges();

const detectChangesSpy = spyOn(grid.cdr, 'detectChanges').and.callThrough();
const cellElem = fix.debugElement.query(By.css(CELL_CLASS));
const input = cellElem.query(By.css('input'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export let gridsubscriptions: Subscription [] = [];
export const setupGridScrollDetection = (fixture: ComponentFixture<any>, grid: GridType) => {
gridsubscriptions.push(grid.verticalScrollContainer.chunkLoad.subscribe(() => fixture.detectChanges()));
gridsubscriptions.push(grid.parentVirtDir.chunkLoad.subscribe(() => fixture.detectChanges()));
gridsubscriptions.push(grid.activeNodeChange.subscribe(() => grid.cdr.detectChanges()));
gridsubscriptions.push(grid.selected.subscribe(() => grid.cdr.detectChanges()));
};

export const setupHierarchicalGridScrollDetection = (fixture: ComponentFixture<any>, hierarchicalGrid: IgxHierarchicalGridComponent) => {
Expand Down
2 changes: 1 addition & 1 deletion src/app/grid-performance/grid-performance.sample.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h4 class="sample-title"> Fixed Size Rows</h4>
</igx-grid-toolbar-actions>
</igx-grid-toolbar>
@for (c of columns; track c) {
<igx-column width='auto' [sortable]="true" [filterable]="true" [resizable]="true" [field]="c.field" [header]="c.field">
<igx-column width='auto' [editable]="true" [sortable]="true" [filterable]="true" [resizable]="true" [field]="c.field" [header]="c.field">
</igx-column>
}
</igx-grid>
Expand Down
Loading