From e1e7dcf4b7e637ad80e0339ee27a6a60d66aebb8 Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Wed, 11 Feb 2026 16:49:20 +0100 Subject: [PATCH] :bug: Fix little bug --- .../management/forms/border_radius.cljs | 8 +--- .../management/forms/controls/combobox.cljs | 39 ++++++++++--------- 2 files changed, 22 insertions(+), 25 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/management/forms/border_radius.cljs b/frontend/src/app/main/ui/workspace/tokens/management/forms/border_radius.cljs index 52e5811019..7310e348a7 100644 --- a/frontend/src/app/main/ui/workspace/tokens/management/forms/border_radius.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/management/forms/border_radius.cljs @@ -7,7 +7,6 @@ (ns app.main.ui.workspace.tokens.management.forms.border-radius (:require - [app.common.types.token :as cto] [app.main.ui.workspace.tokens.management.forms.controls :as token.controls] [app.main.ui.workspace.tokens.management.forms.generic-form :as generic] [rumext.v2 :as mf])) @@ -15,12 +14,7 @@ (mf/defc form* [{:keys [token token-type] :rest props}] - (let [token - (mf/with-memo [token] - (if token - (update token :value cto/join-font-family) - {:type token-type})) - props (mf/spread-props props {:token token + (let [props (mf/spread-props props {:token token :token-type token-type :input-component token.controls/combobox*})] [:> generic/form* props])) diff --git a/frontend/src/app/main/ui/workspace/tokens/management/forms/controls/combobox.cljs b/frontend/src/app/main/ui/workspace/tokens/management/forms/controls/combobox.cljs index 723c93e1f6..4ac19066f9 100644 --- a/frontend/src/app/main/ui/workspace/tokens/management/forms/controls/combobox.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/management/forms/controls/combobox.cljs @@ -60,21 +60,26 @@ (defn replace-active-token [value cursor new-name] - (let [before (subs value 0 cursor) - start (str/last-index-of before "{")] - (if start - (let [after-start (subs value start) + (let [before (subs value 0 cursor) + last-open (str/last-index-of before "{") + last-close (str/last-index-of before "}")] + + (if (and last-open + (or (nil? last-close) + (> last-open last-close))) + + (let [after-start (subs value last-open) close-pos (str/index-of after-start "}") end (if close-pos - (+ start close-pos 1) + (+ last-open close-pos 1) cursor)] - (str (subs value 0 start) + (str (subs value 0 last-open) "{" new-name "}" (subs value end))) - (str (subs value 0 cursor) - "{" new-name "}")))) + "{" new-name "}" + (subs value cursor))))) (defn active-token [value input-node] (let [cursor (.-selectionStart input-node)] @@ -128,7 +133,6 @@ is-open* (mf/use-state false) is-open (deref is-open*) - listbox-id (mf/use-id) filter-term* (mf/use-state "") filter-term (deref filter-term*) @@ -179,7 +183,6 @@ (dom/prevent-default event) (swap! is-open* not))) - resolve-stream (mf/with-memo [token] (if (contains? token :value) @@ -196,14 +199,14 @@ (fm/on-input-change form input-name value) (rx/push! resolve-stream value) - - (if token - (do - (reset! is-open* true) - (reset! filter-term* (:partial token))) - (do - (reset! is-open* false) - (reset! filter-term* "")))))) + + (if token + (do + (reset! is-open* true) + (reset! filter-term* (:partial token))) + (do + (reset! is-open* false) + (reset! filter-term* "")))))) on-option-click (mf/use-fn