0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 07:29:08 -05:00

🐛 Fix colorpicker does not close upon switching to Dashboard

This commit is contained in:
Pablo Alba 2022-11-03 07:37:02 +01:00 committed by Alonso Torres
parent 9981bc7c9a
commit ff0b031c8b

View file

@ -758,10 +758,34 @@
(keep lookup) (keep lookup)
(remove #(= (:frame-id %) frame-id))) (remove #(= (:frame-id %) frame-id)))
all-parents
(reduce (fn [res id]
(into res (cph/get-parent-ids objects id)))
(d/ordered-set)
ids)
find-all-empty-parents
(fn recursive-find-empty-parents [empty-parents]
(let [all-ids (into empty-parents ids)
contains? (partial contains? all-ids)
xform (comp (map lookup)
(filter cph/group-shape?)
(remove #(->> (:shapes %) (remove contains?) seq))
(map :id))
parents (into #{} xform all-parents)]
(if (= empty-parents parents)
empty-parents
(recursive-find-empty-parents parents))))
empty-parents
;; Any parent whose children are moved should be deleted
(into (d/ordered-set) (find-all-empty-parents #{}))
changes changes
(-> (pcb/empty-changes it page-id) (-> (pcb/empty-changes it page-id)
(pcb/with-objects objects) (pcb/with-objects objects)
(pcb/change-parent frame-id moving-shapes))] (pcb/change-parent frame-id moving-shapes)
(pcb/remove-objects empty-parents))]
(when-not (empty? changes) (when-not (empty? changes)
(rx/of (dch/commit-changes changes) (rx/of (dch/commit-changes changes)