diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 1361cb1eb..c217969e1 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -302,13 +302,19 @@ objects (:objects container) unames (volatile! (cfh/get-used-names objects)) + component-children + (d/index-by :id (cfh/get-children-with-self objects (:id component-shape))) + frame-id (or force-frame-id (ctst/get-frame-id-by-position objects (gpt/add orig-pos delta) {:skip-components? true - :bottom-frames? true})) + :bottom-frames? true + ;; We must avoid that destiny frame is inside the component frame + :validator #(nil? (get component-children (:id %)))})) + frame (get-shape container frame-id) - component-frame (get-component-shape (:objects container) frame {:allow-main? true}) + component-frame (get-component-shape objects frame {:allow-main? true}) ids-map (volatile! {}) diff --git a/common/src/app/common/types/shape_tree.cljc b/common/src/app/common/types/shape_tree.cljc index 0b22b1a84..92e8880be 100644 --- a/common/src/app/common/types/shape_tree.cljc +++ b/common/src/app/common/types/shape_tree.cljc @@ -276,9 +276,12 @@ (gpt/point? position)) (let [frames (get-frames objects options) - frames (sort-z-index-objects objects frames options)] + frames (sort-z-index-objects objects frames options) + ;; Validator is a callback to add extra conditions to the suggested frame + validator (or (get options :validator) #(-> true))] (or (d/seek #(and ^boolean (some? position) - ^boolean (gsh/has-point? % position)) + ^boolean (gsh/has-point? % position) + ^boolean (validator %)) frames) (get objects uuid/zero))))) diff --git a/frontend/src/app/main/data/workspace/libraries_helpers.cljs b/frontend/src/app/main/data/workspace/libraries_helpers.cljs index 5a66ab309..d19e776f3 100644 --- a/frontend/src/app/main/data/workspace/libraries_helpers.cljs +++ b/frontend/src/app/main/data/workspace/libraries_helpers.cljs @@ -161,9 +161,7 @@ component (:data library) position - components-v2 - ;; The position can generate a frame calculation inside the base component so we force the frame-id - {:force-frame-id frame-id}) + components-v2) first-shape (cond-> (first new-shapes) (not (nil? parent-id))