From 697b6776ba02b84df1722ce3d0ae2f2fcec85498 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 5 Jun 2024 06:38:22 +0200 Subject: [PATCH] :bug: Fix color palette default library --- CHANGES.md | 5 +++-- frontend/src/app/main/ui/workspace/color_palette.cljs | 2 +- frontend/src/app/main/ui/workspace/libraries.cljs | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 183eb324f..58d5dc6b0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -19,12 +19,13 @@ - Layout and scrollign fixes for the bottom palette [Taiga Issue #7559](https://tree.taiga.io/project/penpot/issue/7559) - Fix expand libraries when search results are present [Taiga issue #7876](https://tree.taiga.io/project/penpot/issue/7876) +- Fix color palette default library [Taiga #8029](https://tree.taiga.io/project/penpot/issue/8029) ## 2.0.3 ### :bug: Bugs fixed -- Fix chrome scrollbar styling [Taiga Issue #7852](https://tree.taiga.io/project/penpot/issue/7852) +- Fix chrome scrollbar styling [Taiga #7852](https://tree.taiga.io/project/penpot/issue/7852) - Fix incorrect password encoding on create-profile manage scritp [Github #3651](https://github.com/penpot/penpot/issues/3651) @@ -37,7 +38,7 @@ ### :bug: Bugs fixed -- Fix color palette sorting [Taiga Issue #7458](https://tree.taiga.io/project/penpot/issue/7458) +- Fix color palette sorting [Taiga #7458](https://tree.taiga.io/project/penpot/issue/7458) - Fix style scoping problem with imported SVG [Taiga #7671](https://tree.taiga.io/project/penpot/issue/7671) diff --git a/frontend/src/app/main/ui/workspace/color_palette.cljs b/frontend/src/app/main/ui/workspace/color_palette.cljs index 7fb9587c0..5dccc51dc 100644 --- a/frontend/src/app/main/ui/workspace/color_palette.cljs +++ b/frontend/src/app/main/ui/workspace/color_palette.cljs @@ -149,7 +149,7 @@ shared-libs (mf/deref refs/workspace-libraries) colors (mf/use-state [])] - (mf/with-effect [selected] + (mf/with-effect [selected shared-libs] (let [colors' (cond (= selected :recent) (reverse recent-colors) (= selected :file) (->> (vals file-colors) (sort-by :name)) diff --git a/frontend/src/app/main/ui/workspace/libraries.cljs b/frontend/src/app/main/ui/workspace/libraries.cljs index ddbfe354a..e28f28f96 100644 --- a/frontend/src/app/main/ui/workspace/libraries.cljs +++ b/frontend/src/app/main/ui/workspace/libraries.cljs @@ -16,6 +16,7 @@ [app.common.uuid :as uuid] [app.main.data.modal :as modal] [app.main.data.users :as du] + [app.main.data.workspace.colors :as mdc] [app.main.data.workspace.libraries :as dwl] [app.main.refs :as refs] [app.main.render :refer [component-svg]] @@ -25,6 +26,7 @@ [app.main.ui.components.search-bar :refer [search-bar]] [app.main.ui.components.tab-container :refer [tab-container tab-element]] [app.main.ui.components.title-bar :refer [title-bar]] + [app.main.ui.hooks :as h] [app.main.ui.icons :as i] [app.util.color :as uc] [app.util.dom :as dom] @@ -113,6 +115,7 @@ components (:components library) media (:media library) typographies (:typographies library) + selected (h/use-shared-state mdc/colorpalette-selected-broadcast-key :recent) empty-library? (and (zero? (count colors)) @@ -146,6 +149,7 @@ (let [library-id (some-> (dom/get-current-target event) (dom/get-data "library-id") (parse-uuid))] + (reset! selected library-id) (st/emit! (dwl/link-file-to-library file-id library-id))))) unlink-library @@ -155,6 +159,8 @@ (let [library-id (some-> (dom/get-current-target event) (dom/get-data "library-id") (parse-uuid))] + (when (= library-id @selected) + (reset! selected :file)) (st/emit! (dwl/unlink-file-from-library file-id library-id) (dwl/sync-file file-id library-id)))))