From f7a0c4139a6d373eeaae530a628702cce9abc7c7 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Mon, 18 Aug 2025 13:02:27 +0200 Subject: [PATCH] :bug: Fix you can add a rect into a variant container (#7137) --- common/src/app/common/types/container.cljc | 9 +++++---- frontend/src/app/main/data/workspace/drawing/box.cljs | 2 +- frontend/src/app/main/data/workspace/drawing/curve.cljs | 2 +- frontend/src/app/main/data/workspace/path/drawing.cljs | 2 +- frontend/src/app/main/data/workspace/shapes.cljs | 4 ++-- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 0982cab7fb..1ac6f89148 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -389,12 +389,13 @@ [(remap-ids new-shape) (map remap-ids new-shapes)]))) -(defn get-first-not-copy-parent - "Go trough the parents until we find a shape that is not a copy of a component." +(defn get-first-valid-parent + "Go trough the parents until we find a shape that is not a copy of a component nor + a variant container." [objects id] (let [shape (get objects id)] - (if (ctk/in-component-copy? shape) - (get-first-not-copy-parent objects (:parent-id shape)) + (if (or (ctk/in-component-copy? shape) (ctk/is-variant-container? shape)) + (get-first-valid-parent objects (:parent-id shape)) shape))) (defn has-any-copy-parent? diff --git a/frontend/src/app/main/data/workspace/drawing/box.cljs b/frontend/src/app/main/data/workspace/drawing/box.cljs index eefffe628e..353c6e8252 100644 --- a/frontend/src/app/main/data/workspace/drawing/box.cljs +++ b/frontend/src/app/main/data/workspace/drawing/box.cljs @@ -91,7 +91,7 @@ focus (:workspace-focus-selected state) fid (->> (ctst/top-nested-frame objects initial) - (ctn/get-first-not-copy-parent objects) ;; We don't want to change the structure of component copies + (ctn/get-first-valid-parent objects) ;; We don't want to change the structure of component copies :id) flex-layout? (ctl/flex-layout? objects fid) diff --git a/frontend/src/app/main/data/workspace/drawing/curve.cljs b/frontend/src/app/main/data/workspace/drawing/curve.cljs index e8546ffb22..9846a05ccf 100644 --- a/frontend/src/app/main/data/workspace/drawing/curve.cljs +++ b/frontend/src/app/main/data/workspace/drawing/curve.cljs @@ -36,7 +36,7 @@ position (path.segment/get-handler-point content 0 nil) frame-id (->> (ctst/top-nested-frame objects position) - (ctn/get-first-not-copy-parent objects) ;; We don't want to change the structure of component copies + (ctn/get-first-valid-parent objects) ;; We don't want to change the structure of component copies :id) flex-layout? (ctl/flex-layout? objects frame-id) diff --git a/frontend/src/app/main/data/workspace/path/drawing.cljs b/frontend/src/app/main/data/workspace/path/drawing.cljs index ceb9a8872f..fecee394ce 100644 --- a/frontend/src/app/main/data/workspace/path/drawing.cljs +++ b/frontend/src/app/main/data/workspace/path/drawing.cljs @@ -286,7 +286,7 @@ (gpt/point)) frame-id (->> (ctst/top-nested-frame objects position) - (ctn/get-first-not-copy-parent objects) ;; We don't want to change the structure of component copies + (ctn/get-first-valid-parent objects) ;; We don't want to change the structure of component copies :id) flex-layout? (ctl/flex-layout? objects frame-id) drop-index (when flex-layout? (gsl/get-drop-index frame-id objects position))] diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index 86131c67c3..06e9c200b6 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -232,8 +232,8 @@ (:parent-id base)) ;; If the parent-id or the frame-id are component-copies, we need to get the first not copy parent - parent-id (:id (ctn/get-first-not-copy-parent objects parent-id)) ;; We don't want to change the structure of component copies - frame-id (:id (ctn/get-first-not-copy-parent objects frame-id)) + parent-id (:id (ctn/get-first-valid-parent objects parent-id)) ;; We don't want to change the structure of component copies + frame-id (:id (ctn/get-first-valid-parent objects frame-id)) shape (cts/setup-shape