mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 21:01:39 +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."
|
"Assoc a k v pair, in the order position just before the other key."
|
||||||
[o ks k v before-k]
|
[o ks k v before-k]
|
||||||
(let [f (fn [o']
|
(let [f (fn [o']
|
||||||
(cond-> (reduce
|
(let [found (volatile! false)
|
||||||
|
result (reduce
|
||||||
(fn [acc [k' v']]
|
(fn [acc [k' v']]
|
||||||
(cond
|
(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
|
(= k k') acc
|
||||||
:else (assoc acc k' v')))
|
:else (assoc acc k' v')))
|
||||||
(ordered-map)
|
(ordered-map)
|
||||||
o')
|
o')]
|
||||||
(not before-k) (assoc k v)))]
|
(if (or (not before-k) (not @found))
|
||||||
|
(assoc result k v)
|
||||||
|
result)))]
|
||||||
(if (seq ks)
|
(if (seq ks)
|
||||||
(oupdate-in o ks f)
|
(oupdate-in o ks f)
|
||||||
(f o))))
|
(f o))))
|
||||||
|
|
|
@ -65,13 +65,7 @@
|
||||||
to (nth tree to-index)
|
to (nth tree to-index)
|
||||||
before (case position
|
before (case position
|
||||||
:top to
|
:top to
|
||||||
:bot (let [v (nth tree (inc to-index) nil)]
|
:bot (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))
|
|
||||||
:center nil)
|
:center nil)
|
||||||
|
|
||||||
prev-before (if (:group? from)
|
prev-before (if (:group? from)
|
||||||
|
@ -87,6 +81,7 @@
|
||||||
(= :bot position)
|
(= :bot position)
|
||||||
(:group? to)
|
(:group? to)
|
||||||
(not (get collapsed-paths (:path to)))))
|
(not (get collapsed-paths (:path to)))))
|
||||||
|
|
||||||
from-path (:path from)
|
from-path (:path from)
|
||||||
to-parent-path (if drop-as-direct-group-child?
|
to-parent-path (if drop-as-direct-group-child?
|
||||||
(:path to)
|
(:path to)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue