From 51e50ac301a10e249a1d6c257d4c14f1b6026ad5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 23 Nov 2023 11:25:14 +0100 Subject: [PATCH] :bug: Fix validation when pasting a copy into a component --- .../app/main/data/workspace/selection.cljs | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 105598503..ee774bbd8 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -17,6 +17,7 @@ [app.common.geom.shapes :as gsh] [app.common.record :as cr] [app.common.types.component :as ctk] + [app.common.types.container :as ctn] [app.common.types.file :as ctf] [app.common.types.page :as ctp] [app.common.types.shape.interactions :as ctsi] @@ -428,14 +429,18 @@ bool? (cfh/bool-shape? obj) new-id (ids-map (:id obj)) parent-id (or parent-id frame-id) + parent (get objects parent-id) name (:name obj) - is-component-root? (or (:saved-component-root obj) - ;; Backward compatibility - (:saved-component-root? obj) - (ctk/instance-root? obj)) + is-component-root? (or (:saved-component-root obj) + ;; Backward compatibility + (:saved-component-root? obj) + (ctk/instance-root? obj)) duplicating-component? (or duplicating-component? (ctk/instance-head? obj)) - is-component-main? (ctk/main-instance? obj) + is-component-main? (ctk/main-instance? obj) + into-component? (and duplicating-component? + (ctn/in-any-component? objects parent)) + regenerate-component (fn [changes shape] (let [components-v2 (dm/get-in library-data [:options :components-v2]) @@ -453,8 +458,10 @@ :main-instance :use-for-thumbnail) - (cond-> - (or frame? group? bool?) + (cond-> into-component? + (dissoc :component-root)) + + (cond-> (or frame? group? bool?) (assoc :shapes [])) (gsh/move delta)