Added function to unselect nodes on pressing esc
This commit is contained in:
parent
790648dd26
commit
11bff8f180
1 changed files with 4 additions and 0 deletions
|
|
@ -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<boolean>(
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue