From 340fe752049940f2e97f8012d3d47fb76159d50c Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Fri, 28 Jul 2023 13:11:24 +0200 Subject: [PATCH] :bug: Fix copies have select color wrong --- common/src/app/common/types/container.cljc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 8b98382859..9ebac327a0 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -113,22 +113,26 @@ :else (get-component-shape objects (get objects (:parent-id shape)) options)))) -(defn in-component-main? - "Check if the shape is inside a component non-main instance. - Note that we must iterate on the parents because non-root shapes in - a main component have not any discriminating attribute." + +(defn component-main? + "Check if the shape is a component main instance or is inside one." [objects shape] - (let [component-shape (get-component-shape objects shape {:allow-main? true})] - (:main-instance component-shape))) + (cond + (or (nil? shape) (cph/root? shape)) + false + (ctk/main-instance? shape) + true + :else + (component-main? objects (get objects (:parent-id shape))))) (defn in-any-component? "Check if the shape is part of any component (main or copy), wether it's head or not." [objects shape] (or (ctk/in-component-copy? shape) - (ctk/main-instance? shape) - (in-component-main? objects shape))) + (ctk/instance-head? shape) + (component-main? objects shape))) (defn make-component-shape "Clone the shape and all children. Generate new ids and detach