From 131e4f2446f70a14da2596b846867e5f8f466c43 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 21 Mar 2023 16:50:59 +0100 Subject: [PATCH] :bug: Fix nested frame interaction created flow in wrong frame --- CHANGES.md | 1 + common/src/app/common/pages/helpers.cljc | 19 +++++++++++++++++++ .../app/main/data/workspace/interactions.cljs | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 7df537747..8a3db46c3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -33,6 +33,7 @@ - Fix problem with alt getting stuck when alt+tab [Taiga #5013](https://tree.taiga.io/project/penpot/issue/5013) - Fix problem with z positioning of elements [Taiga #5014](https://tree.taiga.io/project/penpot/issue/5014) - Fix problem in Firefox with scroll jumping when changin pages [#3052](https://github.com/penpot/penpot/issues/3052) +- Fix nested frame interaction created flow in wrong frame [Taiga #5043](https://tree.taiga.io/project/penpot/issue/5043) ### :heart: Community contributions by (Thank you!) - To @ondrejkonec: for contributing to the code with: diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index a6ad3bfea..63273414b 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -171,6 +171,25 @@ (get objects) (get-frame objects))))) +(defn get-root-frame + [objects shape-id] + + (let [frame-id + (if (frame-shape? objects shape-id) + shape-id + (dm/get-in objects [shape-id :frame-id])) + + frame (get objects frame-id)] + (cond + (or (root? frame) (nil? frame)) + nil + + (root-frame? frame) + frame + + :else + (get-root-frame objects (:frame-id frame))))) + (defn valid-frame-target? [objects parent-id shape-id] (let [shape (get objects shape-id)] diff --git a/frontend/src/app/main/data/workspace/interactions.cljs b/frontend/src/app/main/data/workspace/interactions.cljs index 9a141f22d..b9f080a8a 100644 --- a/frontend/src/app/main/data/workspace/interactions.cljs +++ b/frontend/src/app/main/data/workspace/interactions.cljs @@ -112,7 +112,7 @@ (watch [_ state _] (let [page-id (:current-page-id state) objects (wsh/lookup-page-objects state page-id) - frame (cph/get-frame objects shape) + frame (cph/get-root-frame objects (:id shape)) flows (get-in state [:workspace-data :pages-index page-id