From a94a7221fbbab9385c2a0c7aa36fc74dc78373d0 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 21 Apr 2026 21:16:57 +0000 Subject: [PATCH] :zap: Memoize options in text-decoration-options* component Wrap the two radio-button option maps in mf/with-memo [token-applied] so the vector and its (tr ...) calls are evaluated only when the token-applied prop changes, not on every render. Signed-off-by: Andrey Antukh --- .../workspace/sidebar/options/menus/text.cljs | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs index 1480002220..63138c6fb9 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/text.cljs @@ -190,6 +190,19 @@ [{:keys [values on-change on-blur token-applied]}] (let [token-row (contains? cf/flags :token-typography-row) text-decoration (some-> (:text-decoration values) d/name) + options + (mf/with-memo [token-applied] + [{:value "underline" + :id "underline-text-decoration" + :disabled (and token-row (some? token-applied)) + :label (tr "workspace.options.text-options.underline" (sc/get-tooltip :underline)) + :icon i/text-underlined} + {:value "line-through" + :id "line-through-text-decoration" + :disabled (and token-row (some? token-applied)) + :label (tr "workspace.options.text-options.strikethrough" (sc/get-tooltip :line-through)) + :icon i/text-stroked}]) + handle-change (mf/use-fn (mf/deps on-change on-blur) @@ -206,16 +219,7 @@ :name "text-decoration-options" :disabled (and token-row (some? token-applied)) :allow-empty true - :options [{:value "underline" - :id "underline-text-decoration" - :disabled (and token-row (some? token-applied)) - :label (tr "workspace.options.text-options.underline" (sc/get-tooltip :underline)) - :icon i/text-underlined} - {:value "line-through" - :id "line-through-text-decoration" - :disabled (and token-row (some? token-applied)) - :label (tr "workspace.options.text-options.strikethrough" (sc/get-tooltip :line-through)) - :icon i/text-stroked}]}]])) + :options options}]])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Helpers