From 466f27eb7cc2b4dd503408f35a65c3da02d82d0b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 21 Apr 2026 21:14:24 +0000 Subject: [PATCH] :zap: 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 --- .../workspace/sidebar/options/menus/text.cljs | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 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 d13594b525..9ef7db17e8 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 @@ -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]}]