fix(selection): do not select hidden nodes closes #2679
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user