mirror of
https://github.com/penpot/penpot.git
synced 2025-04-11 06:21:30 -05:00
🐛 Prevent to group with circular deps.
This commit is contained in:
parent
1c42ace096
commit
bc655ed9ef
1 changed files with 15 additions and 0 deletions
|
@ -95,6 +95,20 @@
|
|||
;; 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
|
||||
(ptk/reify ::group-selected
|
||||
ptk/WatchEvent
|
||||
|
@ -102,6 +116,7 @@
|
|||
(let [page-id (:current-page-id state)
|
||||
objects (dwc/lookup-page-objects state page-id)
|
||||
selected (get-in state [:workspace-local :selected])
|
||||
selected (clean-selected objects selected)
|
||||
shapes (shapes-for-grouping objects selected)]
|
||||
(when-not (empty? shapes)
|
||||
(let [[group rchanges uchanges] (prepare-create-group page-id shapes "Group-" false)]
|
||||
|
|
Loading…
Add table
Reference in a new issue