From dfd992aa498edec48572ef9a6657193c9e3cef8e Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 21 Apr 2026 21:15:09 +0000 Subject: [PATCH] :zap: 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 --- .../workspace/sidebar/options/menus/text.cljs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 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 9ef7db17e8..119131c983 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 @@ -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]}]