diff --git a/frontend/src/app/main/data/workspace/common.cljs b/frontend/src/app/main/data/workspace/common.cljs index f396d85474..08546d6bb6 100644 --- a/frontend/src/app/main/data/workspace/common.cljs +++ b/frontend/src/app/main/data/workspace/common.cljs @@ -420,19 +420,26 @@ (reverse) (into (d/ordered-set))) - empty-parents-xform - (comp - (map (fn [id] (get objects id))) - (map (fn [{:keys [shapes type] :as obj}] - (when (and (= :group type) - (zero? (count (remove #(contains? ids %) shapes)))) - obj))) - (take-while some?) - (map :id)) + find-all-empty-parents (fn recursive-find-empty-parents [empty-parents] + (let [all-ids (into empty-parents ids) + empty-parents-xform + (comp + (map (fn [id] (get objects id))) + (map (fn [{:keys [shapes type] :as obj}] + (when (and (= :group type) + (zero? (count (remove #(contains? all-ids %) shapes)))) + obj))) + (take-while some?) + (map :id)) + calculated-empty-parents (into #{} empty-parents-xform all-parents)] + + (if (= empty-parents calculated-empty-parents) + empty-parents + (recursive-find-empty-parents calculated-empty-parents)))) empty-parents ;; Any parent whose children are all deleted, must be deleted too. - (into (d/ordered-set) empty-parents-xform all-parents) + (into (d/ordered-set) (find-all-empty-parents #{})) changes (-> (pcb/empty-changes it page-id) (pcb/with-page page) @@ -448,13 +455,13 @@ (pcb/update-shapes (map :id interacting-shapes) (fn [shape] (update shape :interactions - (fn [interactions] - (when interactions - (d/removev #(and (csi/has-destination %) - (contains? ids (:destination %))) - interactions)))))) + (fn [interactions] + (when interactions + (d/removev #(and (csi/has-destination %) + (contains? ids (:destination %))) + interactions)))))) (cond-> - (seq starting-flows) + (seq starting-flows) (pcb/update-page-option :flows (fn [flows] (reduce #(csp/remove-flow %1 (:id %2)) flows diff --git a/frontend/src/app/main/ui/viewer/shapes.cljs b/frontend/src/app/main/ui/viewer/shapes.cljs index c216224097..f51e920e4d 100644 --- a/frontend/src/app/main/ui/viewer/shapes.cljs +++ b/frontend/src/app/main/ui/viewer/shapes.cljs @@ -318,7 +318,8 @@ props (obj/merge! #js {} props #js {:childs childs :objects objects})] - [:> group-wrapper props])))) + (when (not-empty childs) + [:> group-wrapper props]))))) (defn bool-container-factory [objects]