diff --git a/CHANGES.md b/CHANGES.md index 5ae7135d2..660104c6b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -17,6 +17,8 @@ - Fix problem with rules position on changing pages [Taiga #4847](https://tree.taiga.io/project/penpot/issue/4847) - Fix error streen when uploading wrong SVG [#2995](https://github.com/penpot/penpot/issues/2995) +- Fix error streen when uploading wrong SVG [#2995](https://github.com/penpot/penpot/issues/2995) +- Fix selecting children from hidden parent layers [Taiga #4934](https://tree.taiga.io/project/penpot/issue/4934) ### :arrow_up: Deps updates diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index eedc9beff..76062cee4 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -120,6 +120,16 @@ (recur (conj result parent-id) parent-id) result)))) +(defn hidden-parent? + "Checks the parent for the hidden property" + [objects shape-id] + (let [parent-id (dm/get-in objects [shape-id :parent-id])] + (cond + (or (nil? parent-id) (nil? shape-id) (= shape-id uuid/zero) (= parent-id uuid/zero)) false + (dm/get-in objects [parent-id :hidden]) true + :else + (recur objects parent-id)))) + (defn get-parent-ids-with-index "Returns a tuple with the list of parents and a map with the position within each parent" [objects shape-id] diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index 7d89be785..ab0d5aa64 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -244,6 +244,7 @@ hover-shape (->> ids (remove remove-id?) + (remove (partial cph/hidden-parent? objects)) (filter #(or (empty? focus) (cp/is-in-focus? objects focus %))) (first) (get objects))] diff --git a/frontend/src/app/util/snap_data.cljs b/frontend/src/app/util/snap_data.cljs index c7b00e954..f9cf779fa 100644 --- a/frontend/src/app/util/snap_data.cljs +++ b/frontend/src/app/util/snap_data.cljs @@ -82,7 +82,9 @@ grid-y-data (get-grids-snap-points frame :y)] (cond-> page-data - (not (ctl/any-layout-descent? objects frame)) + (and (not (ctl/any-layout-descent? objects frame)) + (not (:hidden frame)) + (not (cph/hidden-parent? objects frame-id))) (-> ;; Update root frame information (assoc-in [uuid/zero :objects-data frame-id] frame-data) @@ -106,7 +108,9 @@ :id (:id shape) :pt %)))] (cond-> page-data - (not (ctl/any-layout-descent? objects shape)) + (and (not (ctl/any-layout-descent? objects shape)) + (not (:hidden shape)) + (not (cph/hidden-parent? objects (:id shape)))) (-> (assoc-in [frame-id :objects-data (:id shape)] shape-data) (update-in [frame-id :x] (make-insert-tree-data shape-data :x)) (update-in [frame-id :y] (make-insert-tree-data shape-data :y)))))) @@ -124,9 +128,11 @@ :pt %)))] (if-let [frame-id (:frame-id guide)] ;; Guide inside frame, we add the information only on that frame - (-> page-data - (assoc-in [frame-id :objects-data (:id guide)] guide-data) - (update-in [frame-id (:axis guide)] (make-insert-tree-data guide-data (:axis guide)))) + (cond-> page-data + (and (not (:hidden frame)) + (not (cph/hidden-parent? objects frame-id))) + (-> (assoc-in [frame-id :objects-data (:id guide)] guide-data) + (update-in [frame-id (:axis guide)] (make-insert-tree-data guide-data (:axis guide))))) ;; Guide outside the frame. We add the information in the global guides data (-> page-data