From a861691ffdb4de7215a99f5c05e4b5047de78b80 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 11 Jun 2024 13:52:54 +0200 Subject: [PATCH] :bug: Fix change color on imported svg also changes the stroke alignment --- CHANGES.md | 3 +- .../src/app/main/data/workspace/colors.cljs | 2 +- .../frontend_tests/basic_shapes_test.cljs | 34 +++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index beeea77a4..2385cddb8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -35,7 +35,8 @@ - Fix "Attribute overrides in copies are not exported in zip file" [Taiga #8072](https://tree.taiga.io/project/penpot/issue/8072) - Fix group not automatically selected in the Layers panel after creation [Taiga #8078](https://tree.taiga.io/project/penpot/issue/8078) - Fix export boards loses opacity [Taiga #7592](https://tree.taiga.io/project/penpot/issue/7592) -- Fix show in view mode and interactions workflow [Taiga #4711](https://github.com/penpot/penpot/pull/4711) +- Fix show in view mode and interactions workflow +- Fix change color on imported svg also changes the stroke alignment[Taiga #7673](https://github.com/penpot/penpot/pull/7673) ## 2.0.3 diff --git a/frontend/src/app/main/data/workspace/colors.cljs b/frontend/src/app/main/data/workspace/colors.cljs index 70a19585f..71a3903b8 100644 --- a/frontend/src/app/main/data/workspace/colors.cljs +++ b/frontend/src/app/main/data/workspace/colors.cljs @@ -248,7 +248,7 @@ (assoc :stroke-style :solid) (not (contains? new-attrs :stroke-alignment)) - (assoc :stroke-alignment :inner) + (assoc :stroke-alignment :center) :always (d/without-nils))] diff --git a/frontend/test/frontend_tests/basic_shapes_test.cljs b/frontend/test/frontend_tests/basic_shapes_test.cljs index 8f7700120..301773837 100644 --- a/frontend/test/frontend_tests/basic_shapes_test.cljs +++ b/frontend/test/frontend_tests/basic_shapes_test.cljs @@ -9,6 +9,7 @@ [app.common.test-helpers.files :as cthf] [app.common.test-helpers.ids-map :as cthi] [app.common.test-helpers.shapes :as cths] + [app.main.data.workspace.colors :as dc] [app.main.data.workspace.shapes :as dwsh] [cljs.test :as t :include-macros true] [frontend-tests.helpers.state :as ths])) @@ -46,3 +47,36 @@ (t/is (= (count fills') 1)) (t/is (= (:fill-color fill') "#fabada")) (t/is (= (:fill-opacity fill') 1)))))))) + +(t/deftest test-update-stroke + ;; Old shapes without stroke-alignment are rendered as if it is centered + (t/async + done + (let [;; ==== Setup + store + (ths/setup-store + (-> (cthf/sample-file :file1 :page-label :page1) + (cths/add-sample-shape :shape1 :strokes [{:stroke-color "#000000" + :stroke-opacity 1 + :stroke-width 2}]))) + + ;; ==== Action + events + [(dc/change-stroke #{(cthi/id :shape1)} {:color "#FABADA"} 0)]] + + (ths/run-store + store done events + (fn [new-state] + (let [;; ==== Get + shape1' (get-in new-state [:workspace-data + :pages-index + (cthi/id :page1) + :objects + (cthi/id :shape1)]) + stroke' (-> (:strokes shape1') + first)] + + ;; ==== Check + (println stroke') + (t/is (some? shape1')) + (t/is (= (:stroke-alignment stroke') :center)))))))) \ No newline at end of file