From 786513863b887278be75fa724486810b687de0ba Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 12 Mar 2024 11:55:40 +0100 Subject: [PATCH] :bug: Fix problem with duplicate in main component --- common/src/app/common/types/component.cljc | 10 ++++++++++ frontend/src/app/main/data/workspace/selection.cljs | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/types/component.cljc b/common/src/app/common/types/component.cljc index 70b030eaf1..205454d713 100644 --- a/common/src/app/common/types/component.cljc +++ b/common/src/app/common/types/component.cljc @@ -240,3 +240,13 @@ (distinct) (filter #(not (eq % (get comp1 %) (get comp2 %)))) set))) + +(defn allow-duplicate? + [objects shape] + + (let [parent (get objects (:parent-id shape))] + ;; We don't want to change the structure of component copies + (and (not (in-component-copy-not-head? shape)) + ;; Non instance, non copy. We allow + (or (not (instance-head? shape)) + (not (in-component-copy? parent)))))) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 15d3d5ab45..eb5e9e168a 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -709,8 +709,8 @@ (let [page (wsh/lookup-page state) objects (:objects page) selected (->> (wsh/lookup-selected state) - (map #(get objects %)) - (remove #(ctk/in-component-copy-not-root? %)) ;; We don't want to change the structure of component copies + (map (d/getf objects)) + (filter #(ctk/allow-duplicate? objects %)) (map :id) set)] (when (seq selected)