From 67e1081f11e8d368ec6498753d53634af1ce794e Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 12 Jun 2024 13:28:36 +0200 Subject: [PATCH] :bug: Fix open overlay relative to a frame --- CHANGES.md | 1 + frontend/src/app/main/ui/viewer/shapes.cljs | 28 ++++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 65781b268..70ac184d5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -42,6 +42,7 @@ - Fix internal error when I set up a stroke for some objects without and with stroke [Taiga #7558](https://tree.taiga.io/project/penpot/issue/7558) - Toolbar keeps toggling on and off on spacebar press [Taiga #7654](https://github.com/penpot/penpot/pull/7654) - Fix toolbar keeps hiding when click outside workspace [Taiga #7776](https://tree.taiga.io/project/penpot/issue/7776) +- Fix open overlay relative to a frame [Taiga #7563](https://tree.taiga.io/project/penpot/issue/7563) ## 2.0.3 diff --git a/frontend/src/app/main/ui/viewer/shapes.cljs b/frontend/src/app/main/ui/viewer/shapes.cljs index 5832f28ce..833a9fd79 100644 --- a/frontend/src/app/main/ui/viewer/shapes.cljs +++ b/frontend/src/app/main/ui/viewer/shapes.cljs @@ -44,9 +44,17 @@ (or (empty? overlays-ids) (nil? shape) (cfh/root? shape)) base-frame :else (find-relative-to-base-frame (cfh/get-parent objects (:id shape)) objects overlays-ids base-frame))) +(defn- ignore-frame-shape + [shape objects manual?] + (let [shape (cond-> shape ;; When the the interaction is not manual and its origin is a frame, + ;; we need to ignore it on all the find-frame calculations + (and (:frame-id shape) (not manual?)) + (assoc :type :rect)) + objects (assoc objects (:id shape) shape)] + [shape objects])) + (defn- activate-interaction [interaction shape base-frame frame-offset objects overlays] - (case (:action-type interaction) :navigate (when-let [frame-id (:destination interaction)] @@ -58,9 +66,11 @@ (dv/go-to-frame frame-id (:animation interaction))))) :open-overlay - (let [dest-frame-id (:destination interaction) + (let [manual? (= :manual (:overlay-pos-type interaction)) + [shape objects] (ignore-frame-shape shape objects manual?) + dest-frame-id (:destination interaction) dest-frame (get objects dest-frame-id) - relative-to-id (if (= :manual (:overlay-pos-type interaction)) + relative-to-id (if manual? (if (= (:type shape) :frame) ;; manual interactions are always from "self" (:frame-id shape) (:id shape)) @@ -88,7 +98,9 @@ fixed-base?)))) :toggle-overlay - (let [dest-frame-id (:destination interaction) + (let [manual? (= :manual (:overlay-pos-type interaction)) + [shape objects] (ignore-frame-shape shape objects manual?) + dest-frame-id (:destination interaction) dest-frame (get objects dest-frame-id) relative-to-id (if (= :manual (:overlay-pos-type interaction)) (if (= (:type shape) :frame) ;; manual interactions are always from "self" @@ -146,7 +158,9 @@ (st/emit! (dv/close-overlay frame-id))) :toggle-overlay - (let [dest-frame-id (:destination interaction) + (let [manual? (= :manual (:overlay-pos-type interaction)) + [shape objects] (ignore-frame-shape shape objects manual?) + dest-frame-id (:destination interaction) dest-frame (get objects dest-frame-id) relative-to-id (if (= :manual (:overlay-pos-type interaction)) (if (= (:type shape) :frame) ;; manual interactions are always from "self" @@ -178,7 +192,9 @@ :close-overlay - (let [dest-frame-id (:destination interaction) + (let [manual? (= :manual (:overlay-pos-type interaction)) + [shape objects] (ignore-frame-shape shape objects manual?) + dest-frame-id (:destination interaction) dest-frame (get objects dest-frame-id) relative-to-id (if (= :manual (:overlay-pos-type interaction)) (if (= (:type shape) :frame) ;; manual interactions are always from "self"