Remove selection workaround for undo

Always select the first one when no match is found
This commit is contained in:
Andrey Antukh 2025-02-11 12:56:27 +01:00
parent 064e51d24e
commit 50afc4c507

View file

@ -305,29 +305,14 @@
(get-sorted-token-groups tokens-by-type))] (get-sorted-token-groups tokens-by-type))]
(mf/with-effect [tokens-lib selected-token-set-name] (mf/with-effect [tokens-lib selected-token-set-name]
(when tokens-lib (when (and tokens-lib
(if selected-token-set-name (or (nil? selected-token-set-name)
;; WORKAROUND: because we don't have a stable reference (by (and selected-token-set-name
;; ID per example) to token sets, when a set is moved the (not (ctob/get-set tokens-lib selected-token-set-name)))))
;; name/path of the set changes and now can point to not (let [match (->> (ctob/get-sets tokens-lib)
;; existing object; on this cases we perform a best effort (first)
;; search around all existing sets that matches the (:name))]
;; name (and not the path) and select it if it is found (st/emit! (dt/set-selected-token-set-name match)))))
(when-not (ctob/get-set tokens-lib selected-token-set-name)
(let [selected-name (ctob/get-token-set-final-name selected-token-set-name)
match (->> (ctob/get-sets tokens-lib)
(map :name)
(filter (fn [name]
(let [path (ctob/split-token-set-name name)]
(= (peek path) selected-name))))
(first))]
(when match
(st/emit! (dt/set-selected-token-set-name match)))))
(let [match (->> (ctob/get-sets tokens-lib)
(first)
(:name))]
(st/emit! (dt/set-selected-token-set-name match))))))
[:* [:*
[:& token-context-menu] [:& token-context-menu]