From 025385ca4eb64cbe4b62608f805be9c9f8cbf97a Mon Sep 17 00:00:00 2001 From: moklick Date: Wed, 9 Jul 2025 10:04:38 +0200 Subject: [PATCH 1/2] fix(get-node-intersections): calculate overlapping area correctly #5382 --- packages/react/src/hooks/useReactFlow.ts | 6 +++++- packages/react/src/types/instance.ts | 12 ++++++------ .../svelte/src/lib/hooks/useSvelteFlow.svelte.ts | 8 ++++++-- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/packages/react/src/hooks/useReactFlow.ts b/packages/react/src/hooks/useReactFlow.ts index 84b1cb77..7fb66b8f 100644 --- a/packages/react/src/hooks/useReactFlow.ts +++ b/packages/react/src/hooks/useReactFlow.ts @@ -222,7 +222,11 @@ export function useReactFlow 0; - return partiallyVisible || overlappingArea >= nodeRect.width * nodeRect.height; + return ( + partiallyVisible || + overlappingArea >= currNodeRect.width * currNodeRect.height || + overlappingArea >= nodeRect.width * nodeRect.height + ); }) as NodeType[]; }, isNodeIntersecting: (nodeOrRect, area, partially = true) => { diff --git a/packages/react/src/types/instance.ts b/packages/react/src/types/instance.ts index d001486a..b9954fa2 100644 --- a/packages/react/src/types/instance.ts +++ b/packages/react/src/types/instance.ts @@ -105,7 +105,7 @@ export type GeneralHelpers & - ViewportHelperFunctions & { - /** - * React Flow needs to mount the viewport to the DOM and initialize its zoom and pan behavior. - * This property tells you when viewport is initialized. - */ + ViewportHelperFunctions & { + /** + * React Flow needs to mount the viewport to the DOM and initialize its zoom and pan behavior. + * This property tells you when viewport is initialized. + */ viewportInitialized: boolean; }; diff --git a/packages/svelte/src/lib/hooks/useSvelteFlow.svelte.ts b/packages/svelte/src/lib/hooks/useSvelteFlow.svelte.ts index c4869c33..0d16d390 100644 --- a/packages/svelte/src/lib/hooks/useSvelteFlow.svelte.ts +++ b/packages/svelte/src/lib/hooks/useSvelteFlow.svelte.ts @@ -125,7 +125,7 @@ export function useSvelteFlow 0; - return partiallyVisible || overlappingArea >= nodeRect.width * nodeRect.height; + return ( + partiallyVisible || + overlappingArea >= currNodeRect.width * currNodeRect.height || + overlappingArea >= nodeRect.width * nodeRect.height + ); }); }, isNodeIntersecting: ( From 21db22d46a253dc4fd17d65dab201aca53a4a6f4 Mon Sep 17 00:00:00 2001 From: moklick Date: Wed, 9 Jul 2025 12:02:49 +0200 Subject: [PATCH 2/2] chore(changeset): add --- .changeset/popular-apples-invent.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/popular-apples-invent.md diff --git a/.changeset/popular-apples-invent.md b/.changeset/popular-apples-invent.md new file mode 100644 index 00000000..2b460ee6 --- /dev/null +++ b/.changeset/popular-apples-invent.md @@ -0,0 +1,6 @@ +--- +'@xyflow/react': patch +'@xyflow/svelte': patch +--- + +Return intersections correctly of passed node is bigger than intersecting nodes