Skip to content

Commit

Permalink
feat: added onkeydown for renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
vardanmangasaryan committed Jun 27, 2023
1 parent 775758f commit 4bba800
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions packages/core/src/data-editor/data-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2618,6 +2618,17 @@ const DataEditorImpl: React.ForwardRefRenderFunction<DataEditorRef, DataEditorPr
const onKeyDown = React.useCallback(
(event: GridKeyEventArgs) => {
const fn = async () => {

// TODO: why can me undefined?
const markerCell = getMangledCellContent([event.location.col!, event.location.row!]);

Check warning on line 2623 in packages/core/src/data-editor/data-editor.tsx

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion

Check warning on line 2623 in packages/core/src/data-editor/data-editor.tsx

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion

const renderer = getCellRenderer(markerCell);

renderer?.onKeyDown?.({
...event,
cell: markerCell,
})

let cancelled = false;
if (onKeyDownIn !== undefined) {
onKeyDownIn({
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/data-grid/cells/cell-types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Theme } from "../..";
import type { Theme, GridKeyEventArgs } from "../..";
import type { SpriteManager } from "../data-grid-sprites";
import type {
InnerGridCell,
Expand Down Expand Up @@ -69,6 +69,12 @@ interface BaseCellRenderer<T extends InnerGridCell> {
} & BaseGridMouseEventArgs
) => T | undefined;

readonly onKeyDown?: (
args: {
readonly cell: T;
} & GridKeyEventArgs
) => void;

readonly onSelect?: (
args: {
readonly cell: T;
Expand Down

0 comments on commit 4bba800

Please sign in to comment.