0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-27 00:49:28 -05:00

🐛 Fix problem when calculating group bounds

This commit is contained in:
alonso.torres 2023-03-31 11:20:42 +02:00
parent d5bbc7b1aa
commit a838dac01b
2 changed files with 41 additions and 29 deletions

View file

@ -133,10 +133,18 @@
(-> (get-shape-filter-bounds shape)
(add-padding (calculate-padding shape true))))
bounds (if (or (:masked-group? shape)
(and (cph/frame-shape? shape)
(not (:show-content shape))))
bounds
(cond
(empty? (:shapes shape))
[(calculate-base-bounds shape)]
(:masked-group? shape)
[(calculate-base-bounds shape)]
(and (cph/frame-shape? shape) (not (:show-content shape)))
[(calculate-base-bounds shape)]
:else
(cph/reduce-objects
objects
(fn [shape]
@ -149,12 +157,13 @@
(:id shape)
(fn [result shape]
(conj result (get-object-bounds objects shape)))
(fn [result child]
(conj result (calculate-base-bounds child)))
[(calculate-base-bounds shape)]))
children-bounds (cond->> (gsr/join-selrects bounds)
children-bounds
(cond->> (gsr/join-selrects bounds)
(not (cph/frame-shape? shape)) (or (:children-bounds shape)))
filters (shape->filters shape)

View file

@ -552,10 +552,13 @@
(loop [current-val init-val
current-id (first root-children)
pending-ids (rest root-children)]
pending-ids (rest root-children)
processed #{}]
(if (contains? processed current-id)
(recur current-val (first pending-ids) (rest pending-ids) processed)
(let [current-shape (get objects current-id)
processed (conj processed current-id)
next-val (reducer-fn current-val current-shape)
next-pending-ids
(if (or (nil? check-children?) (check-children? current-shape))
@ -564,7 +567,7 @@
(if (empty? next-pending-ids)
next-val
(recur next-val (first next-pending-ids) (rest next-pending-ids)))))))))
(recur next-val (first next-pending-ids) (rest next-pending-ids) processed)))))))))
(defn selected-with-children
[objects selected]