0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-25 07:58:49 -05:00

🐛 Fixes problems with top-level shape selection

This commit is contained in:
alonso.torres 2021-01-05 15:19:00 +01:00
parent 66606b7309
commit 2f0fcaf5d3
2 changed files with 19 additions and 5 deletions

View file

@ -175,11 +175,24 @@
([objects {:keys [include-frames?] :or {include-frames? false}}] ([objects {:keys [include-frames?] :or {include-frames? false}}]
(let [lookup #(get objects %) (let [lookup #(get objects %)
root (lookup uuid/zero) root (lookup uuid/zero)
childs (:shapes root) root-children (:shapes root)
shapes (->> childs
(mapv lookup))] lookup-shapes
(cond->> shapes (fn [result id]
include-frames? (filterv #(not= :frame (:type %))))))) (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 (defn select-frames
[objects] [objects]

View file

@ -574,6 +574,7 @@
(let [page-id (:current-page-id state) (let [page-id (:current-page-id state)
objects (lookup-page-objects state page-id) objects (lookup-page-objects state page-id)
to-move-shapes (->> (cp/select-toplevel-shapes objects {:include-frames? false}) to-move-shapes (->> (cp/select-toplevel-shapes objects {:include-frames? false})
(filterv #(= (:frame-id %) uuid/zero))
(mapv :id) (mapv :id)
(d/enumerate) (d/enumerate)
(filterv (comp shapes second))) (filterv (comp shapes second)))