mirror of
https://github.com/penpot/penpot.git
synced 2025-07-14 14:47:17 +02:00
🐛 Fix when retrieving a variant from several with same props, it get the last one
This commit is contained in:
parent
38941d4811
commit
2d36a1f3e0
1 changed files with 2 additions and 1 deletions
|
@ -368,7 +368,8 @@
|
||||||
(update pos assoc :value val))
|
(update pos assoc :value val))
|
||||||
valid-comps (->> variant-components
|
valid-comps (->> variant-components
|
||||||
(remove #(= (:id %) component-id))
|
(remove #(= (:id %) component-id))
|
||||||
(filter #(= (dm/get-in % [:variant-properties pos :value]) val)))
|
(filter #(= (dm/get-in % [:variant-properties pos :value]) val))
|
||||||
|
(reverse))
|
||||||
nearest-comp (apply min-key #(ctv/distance target-props (:variant-properties %)) valid-comps)]
|
nearest-comp (apply min-key #(ctv/distance target-props (:variant-properties %)) valid-comps)]
|
||||||
(when nearest-comp
|
(when nearest-comp
|
||||||
(st/emit! (dwl/component-swap shape (:component-file shape) (:id nearest-comp) true)))))))]
|
(st/emit! (dwl/component-swap shape (:component-file shape) (:id nearest-comp) true)))))))]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue