mirror of
https://github.com/penpot/penpot.git
synced 2026-08-05 20:38:38 +00:00
🐛 Prevent to group with circular deps.
This commit is contained in:
parent
1c42ace096
commit
bc655ed9ef
@ -95,6 +95,20 @@
|
|||||||
;; GROUPS
|
;; GROUPS
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(defn- clean-selected
|
||||||
|
"A helper that cleans selected from circular references."
|
||||||
|
[objects selected]
|
||||||
|
(loop [selected selected
|
||||||
|
id (first selected)
|
||||||
|
items (rest selected)]
|
||||||
|
(if-not id
|
||||||
|
selected
|
||||||
|
(recur (cond-> selected
|
||||||
|
(some #(contains? selected %) (cp/get-parents id objects))
|
||||||
|
(disj id))
|
||||||
|
(first items)
|
||||||
|
(rest items)))))
|
||||||
|
|
||||||
(def group-selected
|
(def group-selected
|
||||||
(ptk/reify ::group-selected
|
(ptk/reify ::group-selected
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
@ -102,6 +116,7 @@
|
|||||||
(let [page-id (:current-page-id state)
|
(let [page-id (:current-page-id state)
|
||||||
objects (dwc/lookup-page-objects state page-id)
|
objects (dwc/lookup-page-objects state page-id)
|
||||||
selected (get-in state [:workspace-local :selected])
|
selected (get-in state [:workspace-local :selected])
|
||||||
|
selected (clean-selected objects selected)
|
||||||
shapes (shapes-for-grouping objects selected)]
|
shapes (shapes-for-grouping objects selected)]
|
||||||
(when-not (empty? shapes)
|
(when-not (empty? shapes)
|
||||||
(let [[group rchanges uchanges] (prepare-create-group page-id shapes "Group-" false)]
|
(let [[group rchanges uchanges] (prepare-create-group page-id shapes "Group-" false)]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user