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 <niwi@niwi.nz>
This commit is contained in:
Andrey Antukh 2026-04-21 21:16:57 +00:00 committed by Belén Albeza
parent b8aa243c2b
commit a94a7221fb

View File

@ -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