diff --git a/common/src/app/common/geom/shapes/bounds.cljc b/common/src/app/common/geom/shapes/bounds.cljc index 3a2bb88c9..81a4f56c7 100644 --- a/common/src/app/common/geom/shapes/bounds.cljc +++ b/common/src/app/common/geom/shapes/bounds.cljc @@ -133,29 +133,38 @@ (-> (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)))) - [(calculate-base-bounds shape)] - (cph/reduce-objects - objects - (fn [shape] - (and (d/not-empty? (:shapes shape)) - (or (not (cph/frame-shape? shape)) - (:show-content shape)) + bounds + (cond + (empty? (:shapes shape)) + [(calculate-base-bounds shape)] - (or (not (cph/group-shape? shape)) - (not (:masked-group? shape))))) + (:masked-group? shape) + [(calculate-base-bounds shape)] - (:id shape) + (and (cph/frame-shape? shape) (not (:show-content shape))) + [(calculate-base-bounds shape)] - (fn [result shape] - (conj result (get-object-bounds objects shape))) + :else + (cph/reduce-objects + objects + (fn [shape] + (and (d/not-empty? (:shapes shape)) + (or (not (cph/frame-shape? shape)) + (:show-content shape)) - [(calculate-base-bounds shape)])) + (or (not (cph/group-shape? shape)) + (not (:masked-group? shape))))) - children-bounds (cond->> (gsr/join-selrects bounds) - (not (cph/frame-shape? shape)) (or (:children-bounds shape))) + (:id shape) + + (fn [result child] + (conj result (calculate-base-bounds child))) + + [(calculate-base-bounds shape)])) + + children-bounds + (cond->> (gsr/join-selrects bounds) + (not (cph/frame-shape? shape)) (or (:children-bounds shape))) filters (shape->filters shape) blur-value (or (-> shape :blur :value) 0)] diff --git a/common/src/app/common/pages/helpers.cljc b/common/src/app/common/pages/helpers.cljc index a4748ba7f..b5ec13c21 100644 --- a/common/src/app/common/pages/helpers.cljc +++ b/common/src/app/common/pages/helpers.cljc @@ -552,19 +552,22 @@ (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)) + (concat (or (:shapes current-shape) []) pending-ids) + pending-ids)] - (let [current-shape (get objects current-id) - next-val (reducer-fn current-val current-shape) - next-pending-ids - (if (or (nil? check-children?) (check-children? current-shape)) - (concat (or (:shapes current-shape) []) pending-ids) - pending-ids)] - - (if (empty? next-pending-ids) - next-val - (recur next-val (first next-pending-ids) (rest next-pending-ids))))))))) + (if (empty? next-pending-ids) + next-val + (recur next-val (first next-pending-ids) (rest next-pending-ids) processed))))))))) (defn selected-with-children [objects selected]