select cell after keyboard navigation (#21366)

* sync selected cell and active cell

* more packages
This commit is contained in:
Alan Ren
2022-12-06 08:53:42 -08:00
committed by GitHub
parent 05eb8dd448
commit bb1f5bfffe
8 changed files with 24 additions and 12 deletions

View File

@@ -45,6 +45,7 @@ export class CellSelectionModel<T> implements Slick.SelectionModel<T, Array<Slic
public init(grid: Slick.Grid<T>) {
this.grid = grid;
this._handler.subscribe(this.grid.onKeyDown, (e: DOMEvent) => this.handleKeyDown(e as KeyboardEvent));
this._handler.subscribe(this.grid.onAfterKeyboardNavigation, (e: Event) => this.handleAfterKeyboardNavigationEvent());
this._handler.subscribe(this.grid.onClick, (e: DOMEvent, args: Slick.OnClickEventArgs<T>) => this.handleCellClick(e as MouseEvent, args));
this._handler.subscribe(this.grid.onHeaderClick, (e: DOMEvent, args: Slick.OnHeaderClickEventArgs<T>) => this.handleHeaderClick(e as MouseEvent, args));
this.grid.registerPlugin(this.selector);
@@ -334,4 +335,11 @@ export class CellSelectionModel<T> implements Slick.SelectionModel<T, Array<Slic
e.stopPropagation();
}
}
private handleAfterKeyboardNavigationEvent(): void {
const activeCell = this.grid.getActiveCell();
if (activeCell) {
this.setSelectedRanges([new Slick.Range(activeCell.row, activeCell.cell)]);
}
}
}