mirror of
https://github.com/penpot/penpot.git
synced 2025-07-29 11:17:13 +02:00
🐛 Fix shape leaking on deletion when is grouped.
This commit is contained in:
parent
2d4e76619f
commit
7fb897a7ad
3 changed files with 22 additions and 6 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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 []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue