From c39cdaf36c2d60da42099e8d60808b40b36efe0d Mon Sep 17 00:00:00 2001 From: bymyself Date: Tue, 9 Sep 2025 16:59:51 -0700 Subject: [PATCH] convert to functional bounds collection --- .../canvas/useSelectionToolboxPosition.ts | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/composables/canvas/useSelectionToolboxPosition.ts b/src/composables/canvas/useSelectionToolboxPosition.ts index 7a8d199f4..3693dbd5c 100644 --- a/src/composables/canvas/useSelectionToolboxPosition.ts +++ b/src/composables/canvas/useSelectionToolboxPosition.ts @@ -38,20 +38,16 @@ export function useSelectionToolboxPosition( visible.value = true // Get bounds from layout store for all selected items - const allBounds: ReadOnlyRect[] = [] - for (const item of selectableItems) { - if (typeof item.id === 'string') { - const layout = layoutStore.getNodeLayoutRef(item.id).value - if (layout) { - allBounds.push([ - layout.bounds.x, - layout.bounds.y, - layout.bounds.width, - layout.bounds.height - ]) - } - } - } + const allBounds: ReadOnlyRect[] = Array.from(selectableItems) + .filter((item) => typeof item.id === 'string') + .map((item) => layoutStore.getNodeLayoutRef(item.id as string).value) + .filter((layout) => layout !== null) + .map((layout) => [ + layout.bounds.x, + layout.bounds.y, + layout.bounds.width, + layout.bounds.height + ]) // Compute union bounds const unionBounds = computeUnionBounds(allBounds)