fix(selection): handle pointer capture for selectionOnDrag closes #4418

This commit is contained in:
moklick
2024-07-10 14:14:24 +02:00
parent 1e429da911
commit 4062a24add
2 changed files with 8 additions and 5 deletions
+6 -3
View File
@@ -117,7 +117,7 @@ export function Pane({
const onPointerDown = (event: ReactPointerEvent): void => { const onPointerDown = (event: ReactPointerEvent): void => {
const { resetSelectedElements, domNode, edgeLookup } = store.getState(); const { resetSelectedElements, domNode, edgeLookup } = store.getState();
containerBounds.current = domNode?.getBoundingClientRect(); containerBounds.current = domNode?.getBoundingClientRect();
container.current?.setPointerCapture(event.pointerId); (event.target as Element)?.setPointerCapture?.(event.pointerId);
if ( if (
!elementsSelectable || !elementsSelectable ||
@@ -222,7 +222,8 @@ export function Pane({
if (event.button !== 0) { if (event.button !== 0) {
return; return;
} }
container.current?.releasePointerCapture(event.pointerId);
(event.target as Element)?.releasePointerCapture?.(event.pointerId);
const { userSelectionRect } = store.getState(); const { userSelectionRect } = store.getState();
// We only want to trigger click functions when in selection mode if // We only want to trigger click functions when in selection mode if
// the user did not move the mouse. // the user did not move the mouse.
@@ -230,7 +231,9 @@ export function Pane({
onClick?.(event); onClick?.(event);
} }
store.setState({ nodesSelectionActive: prevSelectedNodesCount.current > 0 }); if (prevSelectedNodesCount.current > 0) {
store.setState({ nodesSelectionActive: true });
}
resetUserSelection(); resetUserSelection();
onSelectionEnd?.(event); onSelectionEnd?.(event);
@@ -92,7 +92,7 @@
function onPointerDown(event: PointerEvent) { function onPointerDown(event: PointerEvent) {
containerBounds = container.getBoundingClientRect(); containerBounds = container.getBoundingClientRect();
container.setPointerCapture(event.pointerId); (event.target as Element)?.setPointerCapture?.(event.pointerId);
if ( if (
!elementsSelectable || !elementsSelectable ||
@@ -174,7 +174,7 @@
return; return;
} }
container.releasePointerCapture(event.pointerId); (event.target as Element)?.releasePointerCapture?.(event.pointerId);
// We only want to trigger click functions when in selection mode if // We only want to trigger click functions when in selection mode if
// the user did not move the mouse. // the user did not move the mouse.