From 2f0fcaf5d301c0034ccdbe55525388d6bdcee2bf Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 5 Jan 2021 15:19:00 +0100 Subject: [PATCH] :bug: Fixes problems with top-level shape selection --- common/app/common/pages/helpers.cljc | 23 +++++++++++++++---- .../src/app/main/data/workspace/common.cljs | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/common/app/common/pages/helpers.cljc b/common/app/common/pages/helpers.cljc index 53787ac47..f9ce2b24c 100644 --- a/common/app/common/pages/helpers.cljc +++ b/common/app/common/pages/helpers.cljc @@ -175,11 +175,24 @@ ([objects {:keys [include-frames?] :or {include-frames? false}}] (let [lookup #(get objects %) root (lookup uuid/zero) - childs (:shapes root) - shapes (->> childs - (mapv lookup))] - (cond->> shapes - include-frames? (filterv #(not= :frame (:type %))))))) + root-children (:shapes root) + + lookup-shapes + (fn [result id] + (if (nil? id) + result + (let [obj (lookup id) + typ (:type obj) + children (:shapes obj)] + + (cond-> result + (or (not= :frame typ) include-frames?) + (d/concat [obj]) + + (= :frame typ) + (d/concat (map lookup children))))))] + + (reduce lookup-shapes [] root-children)))) (defn select-frames [objects] diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index 45ab3be45..31597600b 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -574,6 +574,7 @@ (let [page-id (:current-page-id state) objects (lookup-page-objects state page-id) to-move-shapes (->> (cp/select-toplevel-shapes objects {:include-frames? false}) + (filterv #(= (:frame-id %) uuid/zero)) (mapv :id) (d/enumerate) (filterv (comp shapes second)))