From 9a976a8f6ece13ffe15e94ff48260aa4da44fb88 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 7 Mar 2024 17:42:19 +0100 Subject: [PATCH] :bug: Fix problem with fix scrolling on nested elements --- CHANGES.md | 1 + common/src/app/common/files/helpers.cljc | 9 ++++++++- frontend/src/app/main/ui/viewer/interactions.cljs | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 541b6e1b6..66073f114 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -128,6 +128,7 @@ - Fix problem with shadow negative spread [Github #3421](https://github.com/penpot/penpot/issues/3421) - Fix problem with linked colors to strokes [Github #3522](https://github.com/penpot/penpot/issues/3522) - Fix problem with hand tool stuck [Github #3318](https://github.com/penpot/penpot/issues/3318) +- Fix problem with fix scrolling on nested elements [Github #3508](https://github.com/penpot/penpot/issues/3508) ## 1.19.5 diff --git a/common/src/app/common/files/helpers.cljc b/common/src/app/common/files/helpers.cljc index 5b31328e6..6203d5db1 100644 --- a/common/src/app/common/files/helpers.cljc +++ b/common/src/app/common/files/helpers.cljc @@ -762,6 +762,13 @@ (recur frame-id frame-parents (rest selected)))))) +(defn fixed-scroll? + [shape] + ^boolean + (and (:fixed-scroll shape) + (= (:parent-id shape) (:frame-id shape)) + (not= (:frame-id shape) uuid/zero))) + (defn fixed? [objects shape-id] (let [ids-to-check @@ -772,4 +779,4 @@ (take-while #(and (not= % uuid/zero) (not (root-frame? objects %))))))] (boolean (->> ids-to-check - (d/seek (fn [id] (dm/get-in objects [id :fixed-scroll]))))))) + (d/seek (fn [id] () (fixed-scroll? (get objects id)))))))) diff --git a/frontend/src/app/main/ui/viewer/interactions.cljs b/frontend/src/app/main/ui/viewer/interactions.cljs index dc4f30ef1..03910ea5d 100644 --- a/frontend/src/app/main/ui/viewer/interactions.cljs +++ b/frontend/src/app/main/ui/viewer/interactions.cljs @@ -41,7 +41,7 @@ (defn get-fixed-ids [objects] - (let [fixed-ids (filter :fixed-scroll (vals objects)) + (let [fixed-ids (filter cfh/fixed-scroll? (vals objects)) ;; we have to consider the children if the fixed element is a group fixed-children-ids