fix: restore node click/dblclick by limiting pointer capture to empty space
All checks were successful
CI / cleanup-branch (push) Has been skipped
CI / build (push) Successful in 59s
CI / docker (push) Successful in 54s
CI / deploy-feature (push) Has been skipped
CI / deploy (push) Successful in 35s

setPointerCapture on the SVG redirected click/dblclick events away from
node <g> elements, breaking drill-down (double-click) and potentially
click selection. Now only capture the pointer when clicking on empty SVG
space, preserving normal event flow on nodes while keeping drag-to-pan.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-03-28 10:11:47 +01:00
parent 79e5caaf7a
commit 99b97c53dd

View File

@@ -64,7 +64,11 @@ export function useZoomPan() {
isPanning.current = true;
didPan.current = false;
panStart.current = { x: e.clientX - state.translateX, y: e.clientY - state.translateY };
(e.currentTarget as SVGSVGElement).setPointerCapture(e.pointerId);
// Only capture pointer on empty space — capturing on nodes would
// redirect click/dblclick to the SVG, breaking node interactions
if (!(e.target as Element).closest('[data-node-id]')) {
(e.currentTarget as SVGSVGElement).setPointerCapture(e.pointerId);
}
},
[state.translateX, state.translateY],
);
@@ -85,7 +89,10 @@ export function useZoomPan() {
const onPointerUp = useCallback(
(e: React.PointerEvent<SVGSVGElement>) => {
isPanning.current = false;
(e.currentTarget as SVGSVGElement).releasePointerCapture(e.pointerId);
const svg = e.currentTarget as SVGSVGElement;
if (svg.hasPointerCapture(e.pointerId)) {
svg.releasePointerCapture(e.pointerId);
}
},
[],
);