mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 15:31:38 +02:00
🐛 Fix tokens set reordering corner case
This commit is contained in:
parent
9115e1a3a3
commit
0099c282b6
2 changed files with 18 additions and 16 deletions
|
@ -82,15 +82,22 @@
|
|||
"Assoc a k v pair, in the order position just before the other key."
|
||||
[o ks k v before-k]
|
||||
(let [f (fn [o']
|
||||
(cond-> (reduce
|
||||
(let [found (volatile! false)
|
||||
result (reduce
|
||||
(fn [acc [k' v']]
|
||||
(cond
|
||||
(and before-k (= k' before-k)) (assoc acc k v k' v')
|
||||
(and before-k (= k' before-k))
|
||||
(do
|
||||
(vreset! found true)
|
||||
(assoc acc k v k' v'))
|
||||
|
||||
(= k k') acc
|
||||
:else (assoc acc k' v')))
|
||||
(ordered-map)
|
||||
o')
|
||||
(not before-k) (assoc k v)))]
|
||||
o')]
|
||||
(if (or (not before-k) (not @found))
|
||||
(assoc result k v)
|
||||
result)))]
|
||||
(if (seq ks)
|
||||
(oupdate-in o ks f)
|
||||
(f o))))
|
||||
|
|
|
@ -65,13 +65,7 @@
|
|||
to (nth tree to-index)
|
||||
before (case position
|
||||
:top to
|
||||
:bot (let [v (nth tree (inc to-index) nil)]
|
||||
;; if the next index is a group, we need to set it as
|
||||
;; nil because if we set a path on different subpath,
|
||||
;; the move algorightm will simply remove the set
|
||||
(if (:group? v)
|
||||
nil
|
||||
v))
|
||||
:bot (nth tree (inc to-index) nil)
|
||||
:center nil)
|
||||
|
||||
prev-before (if (:group? from)
|
||||
|
@ -87,6 +81,7 @@
|
|||
(= :bot position)
|
||||
(:group? to)
|
||||
(not (get collapsed-paths (:path to)))))
|
||||
|
||||
from-path (:path from)
|
||||
to-parent-path (if drop-as-direct-group-child?
|
||||
(:path to)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue