Clicking selection reopens menu

This commit is contained in:
Mitchell McCaffrey 2021-07-22 15:59:46 +10:00
parent ac4ca5b364
commit 4ac4c3aa33
2 changed files with 8 additions and 6 deletions

View File

@ -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;

View File

@ -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<MouseEvent>) {
if (event.target.id() === "selection") {
onSelectionMenuOpen(true);
} else {
onSelectionChange(null);
onSelectionMenuOpen(false);
}
onSelectionChange(null);
onSelectionMenuOpen(false);
}
interactionEmitter?.on("dragStart", handleBrushDown);