From 57c505a9381b8ec8f53855fda1bb1cfd624c9cc1 Mon Sep 17 00:00:00 2001 From: Luis de Dios Date: Wed, 29 Jul 2026 11:55:53 +0200 Subject: [PATCH] :bug: Fix gitch of grid view when switching between teams on list view --- frontend/src/app/main/ui/dashboard.cljs | 84 +++++++++++-------- .../src/app/main/ui/dashboard/deleted.cljs | 12 +-- frontend/src/app/main/ui/dashboard/files.cljs | 10 +-- .../src/app/main/ui/dashboard/projects.cljs | 10 +-- 4 files changed, 52 insertions(+), 64 deletions(-) diff --git a/frontend/src/app/main/ui/dashboard.cljs b/frontend/src/app/main/ui/dashboard.cljs index 20daf964a7..cae49963ec 100644 --- a/frontend/src/app/main/ui/dashboard.cljs +++ b/frontend/src/app/main/ui/dashboard.cljs @@ -27,6 +27,7 @@ [app.main.ui.dashboard.files :refer [files-section*]] [app.main.ui.dashboard.fonts :refer [fonts-page* font-providers-page*]] [app.main.ui.dashboard.import] + [app.main.ui.dashboard.layout-toggle :as lt] [app.main.ui.dashboard.libraries :refer [libraries-page*]] [app.main.ui.dashboard.projects :refer [projects-section*]] [app.main.ui.dashboard.search :refer [search-page*]] @@ -51,7 +52,7 @@ (mf/defc dashboard-content* {::mf/private true} - [{:keys [team projects project section search-term profile default-project]}] + [{:keys [team projects project section search-term profile default-project layout on-layout-change]}] (let [container (mf/use-ref) content-width (mf/use-state 0) @@ -100,18 +101,18 @@ :dashboard-recent (when (seq projects) [:* - [:> projects-section* - {:team team - :projects projects - :profile profile}] + [:> projects-section* {:team team + :projects projects + :profile profile + :layout layout + :on-layout-change on-layout-change}] (when ^boolean show-templates? - [:> templates-section* - {:profile profile - :project-id project-id - :team-id team-id - :default-project-id default-project-id - :content-width @content-width}])]) + [:> templates-section* {:profile profile + :project-id project-id + :team-id team-id + :default-project-id default-project-id + :content-width @content-width}])]) :dashboard-fonts [:> fonts-page* {:team team}] @@ -123,14 +124,15 @@ (when project [:* [:> files-section* {:team team - :project project}] + :project project + :layout layout + :on-layout-change on-layout-change}] (when ^boolean show-templates? - [:> templates-section* - {:profile profile - :team-id team-id - :project-id project-id - :default-project-id default-project-id - :content-width @content-width}])]) + [:> templates-section* {:profile profile + :team-id team-id + :project-id project-id + :default-project-id default-project-id + :content-width @content-width}])]) :dashboard-search [:> search-page* {:team team @@ -155,7 +157,9 @@ :dashboard-deleted [:> deleted-section* {:team team :projects projects - :profile profile}] + :profile profile + :layout layout + :on-layout-change on-layout-change}] nil)])) @@ -313,7 +317,15 @@ (mf/with-memo [projects] (->> projects (filter :is-default) - (first)))] + (first))) + + layout* (hooks/use-persisted-state lt/layout-key lt/default-layout) + layout (deref layout*) + + on-layout-change + (mf/use-fn + (fn [value] + (reset! layout* (keyword value))))] (hooks/use-shortcuts ::dashboard sc/shortcuts-dashboard :dashboard) @@ -347,22 +359,22 @@ ;; team is already set so don't put the team into mf/deps. [:main {:class (stl/css :dashboard) :key (dm/str (:id team))} - [:> sidebar* - {:team team - :projects projects - :project project - :default-project default-project - :profile profile - :section section - :search-term search-term}] - [:> dashboard-content* - {:projects projects - :profile profile - :project project - :default-project default-project - :section section - :search-term search-term - :team team}]]])) + [:> sidebar* {:team team + :projects projects + :project project + :default-project default-project + :profile profile + :section section + :search-term search-term}] + [:> dashboard-content* {:projects projects + :profile profile + :project project + :default-project default-project + :section section + :search-term search-term + :team team + :layout layout + :on-layout-change on-layout-change}]]])) (mf/defc dashboard-page* {::mf/lazy-load true} diff --git a/frontend/src/app/main/ui/dashboard/deleted.cljs b/frontend/src/app/main/ui/dashboard/deleted.cljs index 9a46b697ba..a66714209d 100644 --- a/frontend/src/app/main/ui/dashboard/deleted.cljs +++ b/frontend/src/app/main/ui/dashboard/deleted.cljs @@ -219,16 +219,8 @@ (tr "labels.deleted")]]])) (mf/defc deleted-section* - [{:keys [team projects]}] - (let [layout* (hooks/use-persisted-state lt/layout-key lt/default-layout) - layout (deref layout*) - - on-layout-change - (mf/use-fn - (fn [value] - (reset! layout* (keyword value)))) - - deleted-map + [{:keys [team projects layout on-layout-change]}] + (let [deleted-map (mf/deref ref:deleted-files) projects diff --git a/frontend/src/app/main/ui/dashboard/files.cljs b/frontend/src/app/main/ui/dashboard/files.cljs index ed3781faba..49a1b57f37 100644 --- a/frontend/src/app/main/ui/dashboard/files.cljs +++ b/frontend/src/app/main/ui/dashboard/files.cljs @@ -137,7 +137,7 @@ :on-import on-import}])]])) (mf/defc files-section* - [{:keys [project team]}] + [{:keys [project team layout on-layout-change]}] (let [files (mf/deref refs/files) project-id (get project :id) @@ -160,14 +160,6 @@ selected-files (mf/deref refs/selected-files) - layout* (hooks/use-persisted-state lt/layout-key lt/default-layout) - layout (deref layout*) - - on-layout-change - (mf/use-fn - (fn [value] - (reset! layout* (keyword value)))) - on-file-created (mf/use-fn (fn [file-data] diff --git a/frontend/src/app/main/ui/dashboard/projects.cljs b/frontend/src/app/main/ui/dashboard/projects.cljs index 542395caa7..35b38e8b6a 100644 --- a/frontend/src/app/main/ui/dashboard/projects.cljs +++ b/frontend/src/app/main/ui/dashboard/projects.cljs @@ -313,7 +313,7 @@ (l/derived :recent-files st/state)) (mf/defc projects-section* - [{:keys [team projects profile]}] + [{:keys [team projects profile layout on-layout-change]}] (let [team-id (get team :id) @@ -334,14 +334,6 @@ show-deleted? (:can-edit permisions) - layout* (hooks/use-persisted-state lt/layout-key lt/default-layout) - layout (deref layout*) - - on-layout-change - (mf/use-fn - (fn [value] - (reset! layout* (keyword value)))) - projects (mf/with-memo [projects] (->> projects