diff --git a/CHANGES.md b/CHANGES.md index d4daeef64..7ee9836bd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -73,6 +73,7 @@ - Fix paste elements at bottom of frame [Taig #5253](https://tree.taiga.io/project/penpot/issue/5253) - Fix new-file button on project not redirecting to the new file [Taiga #5610](https://tree.taiga.io/project/penpot/issue/5610) - Fix retrieve user comments in dashboard [Taiga #5607](https://tree.taiga.io/project/penpot/issue/5607) +- Locks shapes when moved inside a locked parent [Taiga #5252](https://tree.taiga.io/project/penpot/issue/5252) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 0e49bf375..95050c190 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -717,17 +717,18 @@ groups-to-delete groups-to-unmask shapes-to-detach shapes-to-reroot shapes-to-deroot shapes-to-unconstraint] (let [ordered-indexes (cph/order-by-indexed-shapes objects ids) - shapes (map (d/getf objects) ordered-indexes)] + shapes (map (d/getf objects) ordered-indexes) + parent (get objects parent-id)] (-> (pcb/empty-changes it page-id) (pcb/with-objects objects) ;; Remove layout-item properties when moving a shape outside a layout - (cond-> (not (ctl/any-layout? objects parent-id)) + (cond-> (not (ctl/any-layout? parent)) (pcb/update-shapes ordered-indexes ctl/remove-layout-item-data)) ;; Remove the hide in viewer flag - (cond-> (and (not= uuid/zero parent-id) (cph/frame-shape? objects parent-id)) + (cond-> (and (not= uuid/zero parent-id) (cph/frame-shape? parent)) (pcb/update-shapes ordered-indexes #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true)))) ;; Move the shapes @@ -759,8 +760,7 @@ ;; Reset constraints depending on the new parent (pcb/update-shapes shapes-to-unconstraint (fn [shape] - (let [parent (get objects parent-id) - frame-id (if (= (:type parent) :frame) + (let [frame-id (if (= (:type parent) :frame) (:id parent) (:frame-id parent)) moved-shape (assoc shape @@ -783,6 +783,10 @@ (assoc :layout-item-v-sizing :fix)) parent))) + ;; If parent locked, lock the added shapes + (cond-> (:blocked parent) + (pcb/update-shapes ordered-indexes #(assoc % :blocked true))) + ;; Resize parent containers that need to (pcb/resize-parents parents))))