From 1ee76fa37e0e280ed62058f775c7531de244a1a6 Mon Sep 17 00:00:00 2001 From: Anish Roy <62830866+iamanishroy@users.noreply.github.com> Date: Sat, 14 Jan 2023 11:35:32 +0000 Subject: [PATCH] renaming/ cleaning --- .../Table/ContextMenu/BasicCellContextMenuActions.tsx | 2 +- src/components/Table/Table.tsx | 8 ++++---- src/components/Table/{useHotKeys.tsx => useHotKey.tsx} | 2 +- .../Table/useMenuAction.tsx} | 0 4 files changed, 6 insertions(+), 6 deletions(-) rename src/components/Table/{useHotKeys.tsx => useHotKey.tsx} (98%) rename src/{contexts/TableKbShortcutContext.tsx => components/Table/useMenuAction.tsx} (100%) diff --git a/src/components/Table/ContextMenu/BasicCellContextMenuActions.tsx b/src/components/Table/ContextMenu/BasicCellContextMenuActions.tsx index a82c6e78..25b6ce0f 100644 --- a/src/components/Table/ContextMenu/BasicCellContextMenuActions.tsx +++ b/src/components/Table/ContextMenu/BasicCellContextMenuActions.tsx @@ -2,7 +2,7 @@ import { Copy as CopyCells } from "@src/assets/icons"; // import Cut from "@mui/icons-material/ContentCut"; import Paste from "@mui/icons-material/ContentPaste"; import { IFieldConfig } from "@src/components/fields/types"; -import { useMenuAction } from "@src/contexts/TableKbShortcutContext"; +import { useMenuAction } from "@src/components/Table/useMenuAction"; // TODO: Remove this and add `handlePaste` function to column config export const BasicContextMenuActions: IFieldConfig["contextMenuActions"] = ( diff --git a/src/components/Table/Table.tsx b/src/components/Table/Table.tsx index 76d504b5..b99c1129 100644 --- a/src/components/Table/Table.tsx +++ b/src/components/Table/Table.tsx @@ -32,11 +32,11 @@ import { updateColumnAtom, selectedCellAtom, } from "@src/atoms/tableScope"; -import { useMenuAction } from "@src/contexts/TableKbShortcutContext"; import { getFieldType, getFieldProp } from "@src/components/fields"; import { useKeyboardNavigation } from "./useKeyboardNavigation"; +import { useMenuAction } from "./useMenuAction"; import { useSaveColumnSizing } from "./useSaveColumnSizing"; -import useHotKeys from "./useHotKeys"; +import useHotKeys from "./useHotKey"; import type { TableRow, ColumnConfig } from "@src/types/table"; export const DEFAULT_ROW_HEIGHT = 41; @@ -186,7 +186,7 @@ export default function Table({ }); const [selectedCell] = useAtom(selectedCellAtom, tableScope); const { handleCopy, handlePaste, handleCut } = useMenuAction(selectedCell); - const { handler } = useHotKeys([ + const { handler: hotKeysHandler } = useHotKeys([ ["mod+C", handleCopy], ["mod+X", handleCut], ["mod+V", handlePaste], @@ -254,7 +254,7 @@ export default function Table({ } onKeyDown={(e) => { handleKeyDown(e); - handler(e); + hotKeysHandler(e); }} >