From 443e41fea4665f603f9a32fd236c8c257f14988a Mon Sep 17 00:00:00 2001 From: Eva Marco Date: Wed, 10 Dec 2025 14:36:08 +0100 Subject: [PATCH] :bug: Fix multiple selection with color tokens (#7941) --- .../sidebar/options/rows/color_row.cljs | 26 +++++++++++-------- .../sidebar/options/rows/stroke_row.cljs | 3 ++- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs index 6e74d9708f..13c5ebaaba 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/color_row.cljs @@ -68,7 +68,7 @@ (mf/defc color-token-row* {::mf/private true} - [{:keys [active-tokens color-token color on-swatch-click-token detach-token open-modal-from-token]}] + [{:keys [active-tokens applied-token-name color on-swatch-click-token detach-token open-modal-from-token]}] (let [;; `active-tokens` may be provided as a `delay` (lazy computation). ;; In that case we must deref it (`@active-tokens`) to force evaluation ;; and obtain the actual value. If it’s already realized (not a delay), @@ -77,21 +77,22 @@ @active-tokens active-tokens) - color-tokens (:color active-tokens) + active-color-tokens (:color active-tokens) - token (some #(when (= (:name %) color-token) %) color-tokens) + token (some #(when (= (:name %) applied-token-name) %) active-color-tokens) on-detach-token (mf/use-fn - (mf/deps detach-token token color-token) + (mf/deps detach-token token applied-token-name) (fn [] - (let [token (or token color-token)] + (let [token (or token applied-token-name)] (detach-token token)))) has-errors (some? (:errors token)) token-name (:name token) resolved (:resolved-value token) - not-active (and (some? active-tokens) (nil? token)) + not-active (and (empty? active-tokens) + (nil? token)) id (dm/str (:id token) "-name") swatch-tooltip-content (cond not-active @@ -109,7 +110,7 @@ #(mf/html [:div [:span (dm/str (tr "workspace.tokens.token-name") ": ")] - [:span {:class (stl/css :token-name-tooltip)} color-token]]))] + [:span {:class (stl/css :token-name-tooltip)} applied-token-name]]))] [:div {:class (stl/css :color-info)} [:div {:class (stl/css-case :token-color-wrapper true @@ -128,7 +129,7 @@ :class (stl/css :token-tooltip)} [:div {:class (stl/css :token-name) :aria-labelledby id} - (or token-name color-token)]] + (or token-name applied-token-name)]] [:div {:class (stl/css :token-actions)} [:> icon-button* {:variant "action" @@ -146,7 +147,11 @@ on-change on-reorder on-detach on-open on-close on-remove origin on-detach-token disable-drag on-focus on-blur select-only select-on-focus on-token-change applied-token]}] - (let [token-color (contains? cfg/flags :token-color) + (let [;; TODO: Remove this workaround fixing `get-attrs*` fn on sidebar/options/shapes/multiple.cljs + applied-token (if (= :multiple applied-token) + nil + applied-token) + token-color (contains? cfg/flags :token-color) libraries (mf/deref refs/files) color-without-hash (mf/use-memo @@ -177,7 +182,6 @@ (-> (deref active-tokens*) (select-keys (get tk/tokens-by-input origin)) (not-empty))))) - on-focus' (mf/use-fn (mf/deps on-focus) @@ -352,7 +356,7 @@ (cond (and token-color applied-token) [:> color-token-row* {:active-tokens tokens - :color-token applied-token + :applied-token-name applied-token :color (dissoc color :ref-id :ref-file) :on-swatch-click-token on-swatch-click-token :detach-token detach-token diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/rows/stroke_row.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/rows/stroke_row.cljs index 1e3207d80e..4f9e167363 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/rows/stroke_row.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/rows/stroke_row.cljs @@ -63,7 +63,8 @@ :data {:index index}) [nil nil]) - stroke-color-token (:stroke-color applied-tokens) + stroke-color-token + (:stroke-color applied-tokens) on-color-change-refactor (mf/use-fn