fix(selection): do not select hidden nodes closes #2679

This commit is contained in:
moklick
2022-12-15 10:54:40 +01:00
parent e1145f3529
commit 2a7effd291
2 changed files with 13 additions and 6 deletions
@@ -102,12 +102,19 @@ const UserSelection = memo(
const onMouseDown = (event: ReactMouseEvent): void => {
const { resetSelectedElements, domNode } = store.getState();
if (!elementsSelectable || !isSelecting || event.button !== 0 || event.target !== container.current || !domNode) {
containerBounds.current = domNode?.getBoundingClientRect();
if (
!elementsSelectable ||
!isSelecting ||
event.button !== 0 ||
event.target !== container.current ||
!containerBounds.current
) {
return;
}
containerBounds.current = domNode.getBoundingClientRect();
const { x, y } = getMousePosition(event, containerBounds.current!);
const { x, y } = getMousePosition(event, containerBounds.current);
resetSelectedElements();
@@ -134,7 +141,7 @@ const UserSelection = memo(
store.setState({ userSelectionActive: true, nodesSelectionActive: false });
const mousePos = getMousePosition(event, containerBounds.current!);
const mousePos = getMousePosition(event, containerBounds.current);
const startX = userSelectionRect.startX ?? 0;
const startY = userSelectionRect.startY ?? 0;
+2 -2
View File
@@ -218,9 +218,9 @@ export const getNodesInside = (
const visibleNodes: Node[] = [];
nodeInternals.forEach((node) => {
const { width, height, selectable = true } = node;
const { width, height, selectable = true, hidden = false } = node;
if (excludeNonSelectableNodes && !selectable) {
if ((excludeNonSelectableNodes && !selectable) || hidden) {
return false;
}