diff --git a/src/components/gui/tabs/table-data-tab.tsx b/src/components/gui/tabs/table-data-tab.tsx index 1569f8c..9ab0a70 100644 --- a/src/components/gui/tabs/table-data-tab.tsx +++ b/src/components/gui/tabs/table-data-tab.tsx @@ -6,7 +6,6 @@ import { LucideArrowRight, LucideDelete, LucideFilter, - LucideLoader, LucidePlus, LucideRefreshCcw, LucideSaveAll, @@ -38,6 +37,9 @@ import ResultStats from "../result-stat"; import isEmptyResultStats from "@/components/lib/empty-stats"; import useTableResultColumnFilter from "../table-result/filter-column"; import { AlertDialogTitle } from "@radix-ui/react-alert-dialog"; +import { useCurrentTab } from "../windows-tab"; +import { KEY_BINDING } from "@/lib/key-matcher"; +import { Toolbar, ToolbarButton } from "../toolbar"; interface TableDataContentProps { tableName: string; @@ -169,6 +171,28 @@ export default function TableDataWindow({ } }, [data]); + const { isActiveTab } = useCurrentTab(); + + useEffect(() => { + if (isActiveTab) { + const handleGlobalKeyBinding = (e: KeyboardEvent) => { + if (KEY_BINDING.commit.match(e)) { + onCommit(); + e.preventDefault(); + e.stopPropagation(); + } else if (KEY_BINDING.discard.match(e)) { + onDiscard(); + e.preventDefault(); + e.stopPropagation(); + } + }; + + document.addEventListener("keydown", handleGlobalKeyBinding); + return () => + document.removeEventListener("keydown", handleGlobalKeyBinding); + } + }, [isActiveTab, onCommit, onDiscard]); + return (