Memoize static options in text-align-options* component

Wrap the four 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:14:24 +00:00 committed by Belén Albeza
parent 6c19c7c0c4
commit 466f27eb7c

View File

@ -48,7 +48,26 @@
(mf/defc text-align-options*
[{:keys [values on-change on-blur]}]
(let [handle-change
(let [options
(mf/with-memo []
[{:value "left"
:id "text-align-left"
:label (tr "workspace.options.text-options.text-align-left")
:icon i/text-align-left}
{:value "center"
:id "text-align-center"
:label (tr "workspace.options.text-options.text-align-center")
:icon i/text-align-center}
{:value "right"
:id "text-align-right"
:label (tr "workspace.options.text-options.text-align-right")
:icon i/text-align-right}
{:value "justify"
:id "text-align-justify"
:label (tr "workspace.options.text-options.text-align-justify")
:icon i/text-justify}])
handle-change
(mf/use-fn
(mf/deps on-change on-blur)
(fn [value]
@ -59,22 +78,7 @@
[:> radio-buttons* {:selected (:text-align values)
:on-change handle-change
:name "align-text-options"
:options [{:value "left"
:id "text-align-left"
:label (tr "workspace.options.text-options.text-align-left")
:icon i/text-align-left}
{:value "center"
:id "text-align-center"
:label (tr "workspace.options.text-options.text-align-center")
:icon i/text-align-center}
{:value "right"
:id "text-align-right"
:label (tr "workspace.options.text-options.text-align-right")
:icon i/text-align-right}
{:value "justify"
:id "text-align-justify"
:label (tr "workspace.options.text-options.text-align-justify")
:icon i/text-justify}]}]]))
:options options}]]))
(mf/defc text-direction-options*
[{:keys [values on-change on-blur]}]