diff --git a/src/components/konva/Selection.tsx b/src/components/konva/Selection.tsx index 65b96a1..f6b6867 100644 --- a/src/components/konva/Selection.tsx +++ b/src/components/konva/Selection.tsx @@ -163,6 +163,7 @@ function Selection({ // Increase stroke width when drawing a selection to // prevent deselection click event from firing hitStrokeWidth: hasItems ? undefined : 100, + id: "selection", }; const x = selection.x * mapWidth; const y = selection.y * mapHeight; diff --git a/src/components/tools/SelectTool.tsx b/src/components/tools/SelectTool.tsx index 8a1399e..3c7c576 100644 --- a/src/components/tools/SelectTool.tsx +++ b/src/components/tools/SelectTool.tsx @@ -1,5 +1,6 @@ import { useState, useEffect, useRef } from "react"; import { Group } from "react-konva"; +import Konva from "konva"; import { useDebouncedStageScale, @@ -28,7 +29,6 @@ import { } from "../../types/Select"; import { RectData } from "../../types/Drawing"; import { useGridCellNormalizedSize } from "../../contexts/GridContext"; -import Konva from "konva"; import Selection from "../konva/Selection"; import { SelectionItemsChangeEventHandler } from "../../types/Events"; import { getSelectionPoints } from "../../helpers/selection"; @@ -223,12 +223,13 @@ function SelectTool({ setIsBrushDown(false); } - function handlePointerClick() { - if (preventSelectionRef.current) { - return; + function handlePointerClick(event: Konva.KonvaEventObject) { + if (event.target.id() === "selection") { + onSelectionMenuOpen(true); + } else { + onSelectionChange(null); + onSelectionMenuOpen(false); } - onSelectionChange(null); - onSelectionMenuOpen(false); } interactionEmitter?.on("dragStart", handleBrushDown);