From f127b5c6ea06686ab6b461818abdd61641d5c4a3 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 22 Jan 2024 09:31:00 +0100 Subject: [PATCH] :bug: Fix react warning on color-selection components --- .../sidebar/options/menus/color_selection.cljs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/color_selection.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/color_selection.cljs index 0fdc7d4747..88f0ef0b40 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/color_selection.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/color_selection.cljs @@ -152,8 +152,9 @@ :library-colors library-colors})) (mf/defc color-selection-menu - {::mf/wrap [#(mf/memo' % (mf/check-props ["shapes"]))]} - [{:keys [shapes file-id shared-libs] :as props}] + {::mf/wrap [#(mf/memo' % (mf/check-props ["shapes"]))] + ::mf/wrap-props false} + [{:keys [shapes file-id shared-libs]}] (let [{:keys [grouped-colors library-colors colors]} (mf/with-memo [shapes file-id shared-libs] (prepare-colors shapes file-id shared-libs)) @@ -175,7 +176,9 @@ (fn [new-color old-color from-picker?] (let [old-color (-> old-color (dissoc :name :path) d/without-nils) - ;; When dragging on the color picker sometimes all the shapes hasn't updated the color to the prev value so we need this extra calculation + ;; When dragging on the color picker sometimes all + ;; the shapes hasn't updated the color to the prev + ;; value so we need this extra calculation shapes-by-old-color (get @grouped-colors* old-color) prev-color (d/seek #(get @grouped-colors* %) @prev-colors*) shapes-by-prev-color (get @grouped-colors* prev-color) @@ -225,7 +228,7 @@ [:div {:class (stl/css :element-content)} [:div {:class (stl/css :selected-color-group)} (for [[index color] (d/enumerate (take 3 library-colors))] - [:& color-row {:key (dm/str "library-color-" (:color color)) + [:& color-row {:key (dm/str "library-color-" index) :color color :index index :on-detach on-detach @@ -239,7 +242,7 @@ (tr "workspace.options.more-lib-colors")]) (when @expand-lib-color (for [[index color] (d/enumerate (drop 3 library-colors))] - [:& color-row {:key (dm/str "library-color-" (:color color)) + [:& color-row {:key (dm/str "library-color-" index) :color color :index index :on-detach on-detach