fix: stuff

This commit is contained in:
David Nguyen
2026-09-26 12:23:47 +10:00
parent 94793c7cce
commit 30a0979573
@@ -98,6 +98,14 @@ export const useEnvelopeCanvasMarquee = ({ onSelect, onEmptyClick }: UseEnvelope
}); });
}; };
/**
* Whether the pointer was actually dragged, as opposed to a plain click
* which leaves the rectangle without an area.
*/
const isMarqueeDrawn = () => {
return selectionRectangle.visible() && selectionRectangle.width() > 0 && selectionRectangle.height() > 0;
};
const onWindowPointerUp = () => { const onWindowPointerUp = () => {
stopTrackingWindow(); stopTrackingWindow();
@@ -111,6 +119,14 @@ export const useEnvelopeCanvasMarquee = ({ onSelect, onEmptyClick }: UseEnvelope
selectionRectangle.visible(false); selectionRectangle.visible(false);
}); });
// A plain click is not a selection, the click handler below deals with
// it. Selecting here would also match anything whose bounding box merely
// contains the point (e.g. a diagonal line), and since this runs after
// other window listeners it would override e.g. a content being placed.
if (!isMarqueeDrawn()) {
return;
}
onSelectRef.current(selectionRectangle.getClientRect()); onSelectRef.current(selectionRectangle.getClientRect());
}; };
@@ -158,7 +174,7 @@ export const useEnvelopeCanvasMarquee = ({ onSelect, onEmptyClick }: UseEnvelope
stage.on('click.marquee tap.marquee', (e) => { stage.on('click.marquee tap.marquee', (e) => {
// A marquee drag just finished, the selection was handled on mouse up. // A marquee drag just finished, the selection was handled on mouse up.
if (selectionRectangle.visible() && selectionRectangle.width() > 0 && selectionRectangle.height() > 0) { if (isMarqueeDrawn()) {
return; return;
} }