🐛 Fix shape leaking on deletion when is grouped.

This commit is contained in:
Andrey Antukh 2020-06-10 08:29:13 +02:00
parent 2d4e76619f
commit 7fb897a7ad
3 changed files with 22 additions and 6 deletions

View file

@ -659,18 +659,27 @@
ptk/WatchEvent
(watch [_ state stream]
(let [page-id (:current-page-id state)
session-id (:session-id state)
objects (get-in state [:workspace-data page-id :objects])
cpindex (cp/calculate-child-parent-map objects)
del-change #(array-map :type :del-obj :id %)
get-empty-parents
(fn get-empty-parents [id]
(let [parent (get objects (get cpindex id))]
(if (and (= :group (:type parent))
(= 1 (count (:shapes parent))))
(lazy-seq (cons (:id parent)
(get-empty-parents (:id parent))))
nil)))
rchanges
(reduce (fn [res id]
(let [chd (cp/get-children id objects)]
(into res (d/concat
(mapv del-change (reverse chd))
[(del-change id)]))))
[(del-change id)]
(map del-change (get-empty-parents id))))))
[]
ids)

View file

@ -153,9 +153,9 @@
(fn [side {:keys [id] :as data}]
(if (= side :center)
(st/emit! (dw/relocate-shape id (:id item) 0))
(let [to-index (if (= side :top) (inc index) index)
(let [to-index (if (= side :top) (inc index) index)
parent-id (cp/get-parent (:id item) objects)]
(st/emit! (dw/relocate-shape id parent-id to-index)))))
(st/emit! (dw/relocate-shape id parent-id to-index)))))
on-hold
(fn []