Memoize static options in text-direction-options* component

Wrap the two radio-button option maps in mf/with-memo [] so the
vector and its (tr ...) calls are evaluated once per mount instead
of on every render.

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Andrey Antukh 2026-04-21 21:15:09 +00:00 committed by Belén Albeza
parent 466f27eb7c
commit dfd992aa49

View File

@ -83,6 +83,17 @@
(mf/defc text-direction-options*
[{:keys [values on-change on-blur]}]
(let [direction (:text-direction values)
options
(mf/with-memo []
[{:value "ltr"
:id "ltr-text-direction"
:label (tr "workspace.options.text-options.direction-ltr")
:icon i/text-ltr}
{:value "rtl"
:id "rtl-text-direction"
:label (tr "workspace.options.text-options.direction-rtl")
:icon i/text-rtl}])
handle-change
(mf/use-fn
(mf/deps on-change on-blur direction)
@ -94,14 +105,7 @@
[:> radio-buttons* {:selected direction
:on-change handle-change
:name "text-direction-options"
:options [{:value "ltr"
:id "ltr-text-direction"
:label (tr "workspace.options.text-options.direction-ltr")
:icon i/text-ltr}
{:value "rtl"
:id "rtl-text-direction"
:label (tr "workspace.options.text-options.direction-rtl")
:icon i/text-rtl}]}]]))
:options options}]]))
(mf/defc vertical-align*
[{:keys [values on-change on-blur]}]