0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-12 18:18:24 -05:00

🐛 Fix error when deleting all children of a nested group

This commit is contained in:
Andrés Moya 2022-03-30 16:02:12 +02:00 committed by Andrey Antukh
parent 134265094c
commit f782a7027a

View file

@ -410,8 +410,8 @@
(fn [changes parent]
(let [children (->> parent :shapes (map (d/getf objects)))
resized-parent (cond
(empty? children)
changes
(empty? children) ;; a parent with no children will be deleted,
nil ;; so it does not need resize
(= (:type parent) :bool)
(gshb/update-bool-selrect parent children objects)
@ -419,21 +419,22 @@
(= (:type parent) :group)
(if (:masked-group? parent)
(gsh/update-mask-selrect parent children)
(gsh/update-group-selrect parent children)))
(gsh/update-group-selrect parent children)))]
(if resized-parent
(let [{rops :rops uops :uops}
(reduce #(generate-operation %1 %2 parent resized-parent)
{:rops [] :uops []}
(keys parent))
{rops :rops uops :uops}
(reduce #(generate-operation %1 %2 parent resized-parent)
{:rops [] :uops []}
(keys parent))
change {:type :mod-obj
:page-id page-id
:id (:id parent)}]
change {:type :mod-obj
:page-id page-id
:id (:id parent)}]
(if (seq rops)
(-> changes
(update :redo-changes conj (assoc change :operations rops))
(update :undo-changes d/preconj (assoc change :operations uops)))
(if (seq rops)
(-> changes
(update :redo-changes conj (assoc change :operations rops))
(update :undo-changes d/preconj (assoc change :operations uops)))
changes))
changes)))]
(-> (reduce resize-parent changes all-parents)