From 11bff8f180c9482d380be33b92dcbb3c43e03d2a Mon Sep 17 00:00:00 2001 From: Lucas Oliveira Date: Mon, 17 Jun 2024 22:29:44 -0300 Subject: [PATCH] Added function to unselect nodes on pressing esc --- .../FlowPage/components/SelectionMenuComponent/index.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx index 9d940b3c6..c5e7d9ad0 100644 --- a/src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/SelectionMenuComponent/index.tsx @@ -4,6 +4,7 @@ import { Button } from "../../../../components/ui/button"; import { GradientGroup } from "../../../../icons/GradientSparkles"; import useFlowStore from "../../../../stores/flowStore"; import { validateSelection } from "../../../../utils/reactflowUtils"; +import { useHotkeys } from "react-hotkeys-hook"; export default function SelectionMenu({ onClick, nodes, @@ -11,6 +12,7 @@ export default function SelectionMenu({ lastSelection, }) { const edges = useFlowStore((state) => state.edges); + const unselectAll = useFlowStore((state) => state.unselectAll); const [disable, setDisable] = useState( lastSelection && edges.length > 0 ? validateSelection(lastSelection!, edges).length > 0 @@ -20,6 +22,8 @@ export default function SelectionMenu({ const [isTransitioning, setIsTransitioning] = useState(false); const [lastNodes, setLastNodes] = useState(nodes); + useHotkeys("esc", unselectAll, { preventDefault: true }); + useEffect(() => { if (isOpen) { return setDisable(validateSelection(lastSelection!, edges).length > 0);