diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index 75df508e01..9fde82d4be 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -325,12 +325,17 @@ x (:x data (- (:x vbc) (/ width 2))) y (:y data (- (:y vbc) (/ height 2))) page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id) frame-id (-> (wsh/lookup-page-objects state page-id) (ctst/top-nested-frame {:x frame-x :y frame-y})) + selected (wsh/lookup-selected state) page-objects (wsh/lookup-page-objects state) - page-selected (wsh/lookup-selected state) - base (cph/get-base-shape page-objects page-selected) - parent-id (:parent-id base) + base (cph/get-base-shape page-objects selected) + selected-frame? (and (= 1 (count selected)) + (= :frame (get-in objects [(first selected) :type]))) + parent-id (if + (or selected-frame? (empty? selected)) frame-id + (:parent-id base)) shape (-> (cts/make-minimal-shape type) (merge data) diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index c96dee88d2..f929e4095d 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -556,9 +556,13 @@ frame-id (ctst/top-nested-frame objects position) selected (wsh/lookup-selected state) page-objects (wsh/lookup-page-objects state) - page-selected (wsh/lookup-selected state) - base (cph/get-base-shape page-objects page-selected) - parent-id (:parent-id base) + base (cph/get-base-shape page-objects selected) + selected-frame? (and (= 1 (count selected)) + (= :frame (get-in objects [(first selected) :type]))) + + parent-id (if + (or selected-frame? (empty? selected)) frame-id + (:parent-id base)) [new-shape new-children] (create-svg-shapes svg-data position objects frame-id parent-id selected true)