From 332bbc71c365cd9e6c9be39b0ca0f86781e3fb89 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 17 Jun 2025 16:13:26 +0200 Subject: [PATCH] :bug: Fix incorrect handling of opacity change on gradient stop --- common/src/app/common/types/color.cljc | 7 +++++-- .../main/ui/workspace/sidebar/options/rows/color_row.cljs | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/types/color.cljc b/common/src/app/common/types/color.cljc index 9173af2437..89b84ea1e9 100644 --- a/common/src/app/common/types/color.cljc +++ b/common/src/app/common/types/color.cljc @@ -22,7 +22,7 @@ ;; SCHEMAS & TYPES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(def valid-color-attrs +(def ^:private required-color-attrs "A set used for proper check if color should contain only one of the attrs listed in this set." #{:image :gradient :color}) @@ -31,7 +31,7 @@ "Check if color has correct color attrs" [color] (let [attrs (set (keys color)) - result (set/intersection attrs valid-color-attrs)] + result (set/intersection attrs required-color-attrs)] (= 1 (count result)))) (def ^:private hex-color-rx @@ -126,6 +126,9 @@ (sm/optional-keys schema:image-color)] [:fn has-valid-color-attrs?]]) +(def color-attrs + (into required-color-attrs (sm/keys schema:color-attrs))) + (def schema:library-color-attrs [:map {:title "ColorAttrs" :closed true} [:id ::sm/uuid] 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 5b97445895..102be8180b 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 @@ -10,6 +10,7 @@ [app.common.colors :as cc] [app.common.data :as d] [app.common.data.macros :as dm] + [app.common.types.color :as types.color] [app.common.types.shape.attrs :refer [default-color]] [app.main.data.modal :as modal] [app.main.data.workspace.colors :as dwc] @@ -125,7 +126,8 @@ (fn [value] (let [color (-> color (assoc :opacity (/ value 100)) - (dissoc :ref-id :ref-file))] + (dissoc :ref-id :ref-file) + (select-keys types.color/color-attrs))] (st/emit! (dwc/add-recent-color color) (on-change color)))))