From 302bfd30074cd1ee8c28949cc39f307cbe0ba33e Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 3 Jul 2023 15:10:49 +0200 Subject: [PATCH] :bug: Fix problems with locked frames --- CHANGES.md | 1 + common/src/app/common/types/shape_tree.cljc | 11 +++++++++-- .../main/data/workspace/drawing/common.cljs | 18 ++++++++++-------- .../src/app/main/data/workspace/shapes.cljs | 4 +++- .../app/main/data/workspace/svg_upload.cljs | 2 +- .../app/main/ui/workspace/viewport/hooks.cljs | 1 + .../main/ui/workspace/viewport/widgets.cljs | 4 +++- 7 files changed, 28 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4e7d3a38d..9de31fbe1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,7 @@ - Fix component and media name validation on assets panel [Taiga #5555](https://tree.taiga.io/project/penpot/issue/5555) - Fix problem with selection shortcuts [Taiga #5492](https://tree.taiga.io/project/penpot/issue/5492) - Fix issue with paths line to curve and concurrent editing [Taiga #5191](https://tree.taiga.io/project/penpot/issue/5191) +- Fix problems with locked layers [Taiga #5139](https://tree.taiga.io/project/penpot/issue/5139) ### :heart: Community contributions by (Thank you!) diff --git a/common/src/app/common/types/shape_tree.cljc b/common/src/app/common/types/shape_tree.cljc index 731f31de2..f84db3e4d 100644 --- a/common/src/app/common/types/shape_tree.cljc +++ b/common/src/app/common/types/shape_tree.cljc @@ -260,7 +260,11 @@ (let [frame-ids (cond->> (all-frames-by-position objects position) (some? excluded) - (remove excluded)) + (remove excluded) + + :always + (remove #(or (dm/get-in objects [% :hidden]) + (dm/get-in objects [% :blocked])))) frame-set (set frame-ids)] @@ -276,7 +280,10 @@ "Search the top nested frame in a list of ids" [objects ids] - (let [frame-ids (->> ids (filter #(cph/frame-shape? objects %))) + (let [frame-ids (->> ids + (filter #(cph/frame-shape? objects %)) + (remove #(or (dm/get-in objects [% :hidden]) + (dm/get-in objects [% :blocked])))) frame-set (set frame-ids)] (loop [current-id (first frame-ids)] (let [current-shape (get objects current-id) diff --git a/frontend/src/app/main/data/workspace/drawing/common.cljs b/frontend/src/app/main/data/workspace/drawing/common.cljs index 796fe8620..ed9790e24 100644 --- a/frontend/src/app/main/data/workspace/drawing/common.cljs +++ b/frontend/src/app/main/data/workspace/drawing/common.cljs @@ -63,20 +63,22 @@ ;; Add & select the created shape to the workspace (rx/concat - (if (= :text (:type shape)) + (if (or (= :text (:type shape)) (= :frame (:type shape))) (rx/of (dwu/start-undo-transaction (:id shape))) (rx/empty)) (rx/of (dwsh/add-shape shape {:no-select? (= tool :curve)})) (if (= :frame (:type shape)) - (->> (uw/ask! {:cmd :selection/query - :page-id page-id - :rect (:selrect shape) - :include-frames? true - :full-frame? true}) - (rx/map #(cph/clean-loops objects %)) - (rx/map #(dwsh/move-shapes-into-frame (:id shape) %))) + (rx/concat + (->> (uw/ask! {:cmd :selection/query + :page-id page-id + :rect (:selrect shape) + :include-frames? true + :full-frame? true}) + (rx/map #(cph/clean-loops objects %)) + (rx/map #(dwsh/move-shapes-into-frame (:id shape) %))) + (rx/of (dwu/commit-undo-transaction (:id shape)))) (rx/empty))))) ;; Delay so the mouse event can read the drawing state diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index 295e880a9..0ef0f39a2 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -143,12 +143,14 @@ (cond-> (ctl/grid-layout? objects frame-id) (pcb/update-shapes [frame-id] ctl/assign-cells)))))) -(defn move-shapes-into-frame [frame-id shapes] +(defn move-shapes-into-frame + [frame-id shapes] (ptk/reify ::move-shapes-into-frame ptk/WatchEvent (watch [it state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) + shapes (->> shapes (remove #(dm/get-in objects [% :blocked]))) changes (-> (pcb/empty-changes it page-id) (pcb/with-objects objects)) changes (prepare-move-shapes-into-frame changes diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index dda47f024..53fbbbafb 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -196,7 +196,7 @@ (-> (update-in [:svg-attrs :style] dissoc :mix-blend-mode) (assoc :blend-mode (-> (get-in shape [:svg-attrs :style :mix-blend-mode]) assert-valid-blend-mode))))) -(defn create-raw-svg [name frame-id svg-data {:keys [tag attrs] :as data}] +(defn create-raw-svg [name frame-id svg-data {:keys [attrs] :as data}] (let [{:keys [x y width height offset-x offset-y]} svg-data] (-> {:id (uuid/next) :type :svg-raw diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index e4787f4ec..0a1245239 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -203,6 +203,7 @@ ids (into (d/ordered-set) + (remove #(dm/get-in objects [% :blocked])) (ctt/sort-z-index objects ids {:bottom-frames? mod?})) grouped? (fn [id] (contains? #{:group :bool} (get-in objects [id :type]))) diff --git a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs index 74dd73d2f..7755d080a 100644 --- a/frontend/src/app/main/ui/workspace/viewport/widgets.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/widgets.cljs @@ -149,7 +149,9 @@ text-pos-x (if (:use-for-thumbnail? frame) 15 0)] (when (not (:hidden frame)) - [:g.frame-title {:id (dm/str "frame-title-" (:id frame)) :transform (vwu/title-transform frame zoom)} + [:g.frame-title {:id (dm/str "frame-title-" (:id frame)) + :transform (vwu/title-transform frame zoom) + :pointer-events (when (:blocked frame) "none")} (when (:use-for-thumbnail? frame) [:svg {:x 0 :y -9