mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 23:31:21 -05:00
🐛 Empty groups were not deleted
This commit is contained in:
parent
0b149dd302
commit
8d1cd2f56d
2 changed files with 25 additions and 17 deletions
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Reference in a new issue