From a576c0404a79b900ad55362766d5d452c00c460e Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Wed, 5 Nov 2025 12:05:00 +0100 Subject: [PATCH] :bug: Fix focus mode across page and file navigation (#7695) --- CHANGES.md | 1 + .../app/main/data/workspace/libraries.cljs | 2 +- .../app/main/data/workspace/path/drawing.cljs | 3 +- .../app/main/data/workspace/path/undo.cljs | 6 ++-- .../app/main/data/workspace/selection.cljs | 33 ++++++++++--------- .../app/main/data/workspace/thumbnails.cljs | 3 +- 6 files changed, 27 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fceece355a..963a6f5d85 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -75,6 +75,7 @@ - Fix paste without selection sends the new element in the back [Taiga #12382](https://tree.taiga.io/project/penpot/issue/12382) - Fix options button does not work for comments created in the lower part of the screen [Taiga #12422](https://tree.taiga.io/project/penpot/issue/12422) - Fix problem when checking usage with removed teams [Taiga #12442](https://tree.taiga.io/project/penpot/issue/12442) +- Fix focus mode persisting across page/file navigation [Taiga #12469](https://tree.taiga.io/project/penpot/issue/12469) ## 2.10.1 diff --git a/frontend/src/app/main/data/workspace/libraries.cljs b/frontend/src/app/main/data/workspace/libraries.cljs index 1ad85bd56a..4fea19a2db 100644 --- a/frontend/src/app/main/data/workspace/libraries.cljs +++ b/frontend/src/app/main/data/workspace/libraries.cljs @@ -1278,7 +1278,7 @@ (watch [_ _ stream] (let [stopper-s (->> stream - (rx/filter #(or (= ::dw/finalize-page (ptk/type %)) + (rx/filter #(or (= ::dwpg/finalize-page (ptk/type %)) (= ::watch-component-changes (ptk/type %))))) workspace-data-s diff --git a/frontend/src/app/main/data/workspace/path/drawing.cljs b/frontend/src/app/main/data/workspace/path/drawing.cljs index 85ae357533..d7a5409f1b 100644 --- a/frontend/src/app/main/data/workspace/path/drawing.cljs +++ b/frontend/src/app/main/data/workspace/path/drawing.cljs @@ -20,6 +20,7 @@ [app.main.data.helpers :as dsh] [app.main.data.workspace.drawing.common :as dwdc] [app.main.data.workspace.edition :as dwe] + [app.main.data.workspace.pages :as-alias dwpg] [app.main.data.workspace.path.changes :as changes] [app.main.data.workspace.path.common :as common] [app.main.data.workspace.path.helpers :as helpers] @@ -43,7 +44,7 @@ (= type :app.main.data.workspace.path.shortcuts/esc-pressed) (= type :app.main.data.workspace.common/clear-edition-mode) (= type :app.main.data.workspace.edition/clear-edition-mode) - (= type :app.main.data.workspace/finalize-page) + (= type ::dwpg/finalize-page) (= event :interrupt) ;; ESC (and ^boolean (mse/mouse-event? event) ^boolean (mse/mouse-double-click-event? event))))) diff --git a/frontend/src/app/main/data/workspace/path/undo.cljs b/frontend/src/app/main/data/workspace/path/undo.cljs index 54b2f3eeaf..bd0a6efa9f 100644 --- a/frontend/src/app/main/data/workspace/path/undo.cljs +++ b/frontend/src/app/main/data/workspace/path/undo.cljs @@ -10,6 +10,8 @@ [app.common.data.undo-stack :as u] [app.common.uuid :as uuid] [app.main.data.workspace.common :as dwc] + [app.main.data.workspace.edition :as-alias dwe] + [app.main.data.workspace.pages :as-alias dwpg] [app.main.data.workspace.path.changes :as changes] [app.main.data.workspace.path.common :as common] [app.main.data.workspace.path.state :as st] @@ -133,8 +135,8 @@ (defn- stop-undo? [event] (let [type (ptk/type event)] - (or (= :app.main.data.workspace.edition/clear-edition-mode type) - (= :app.main.data.workspace/finalize-page type)))) + (or (= ::dwe/clear-edition-mode type) + (= ::dwpg/finalize-page type)))) (def path-content-ref (letfn [(selector [state] diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 16459d7408..5424a280d9 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -24,6 +24,7 @@ [app.main.data.modal :as md] [app.main.data.workspace.collapse :as dwc] [app.main.data.workspace.edition :as dwe] + [app.main.data.workspace.pages :as-alias dwpg] [app.main.data.workspace.specialized-panel :as-alias dwsp] [app.main.data.workspace.undo :as dwu] [app.main.data.workspace.zoom :as dwz] @@ -596,21 +597,21 @@ ptk/WatchEvent (watch [_ state stream] (let [stopper (rx/filter #(or (= ::toggle-focus-mode (ptk/type %)) - (= :app.main.data.workspace/finalize-page (ptk/type %))) stream)] + (= ::dwpg/finalize-page (ptk/type %))) stream)] (when (d/not-empty? (:workspace-focus-selected state)) - (rx/merge - (rx/of dwz/zoom-to-selected-shape - (deselect-all)) - (->> (rx/from-atom refs/workspace-page-objects {:emit-current-value? true}) - (rx/take-until stopper) - (rx/map (comp set keys)) - (rx/buffer 2 1) - (rx/merge-map - ;; While focus is active, update it with any new and deleted shapes - (fn [[old-keys new-keys]] - (let [removed (set/difference old-keys new-keys) - added (set/difference new-keys old-keys)] + (->> (rx/merge + (rx/of dwz/zoom-to-selected-shape + (deselect-all)) + (->> (rx/from-atom refs/workspace-page-objects {:emit-current-value? true}) + (rx/map (comp set keys)) + (rx/buffer 2 1) + (rx/merge-map + ;; While focus is active, update it with any new and deleted shapes + (fn [[old-keys new-keys]] + (let [removed (set/difference old-keys new-keys) + added (set/difference new-keys old-keys)] - (if (or (d/not-empty? added) (d/not-empty? removed)) - (rx/of (update-focus-shapes added removed)) - (rx/empty)))))))))))) + (if (or (d/not-empty? added) (d/not-empty? removed)) + (rx/of (update-focus-shapes added removed)) + (rx/empty))))))) + (rx/take-until stopper))))))) diff --git a/frontend/src/app/main/data/workspace/thumbnails.cljs b/frontend/src/app/main/data/workspace/thumbnails.cljs index 3e330baa0a..a8ff8fedf9 100644 --- a/frontend/src/app/main/data/workspace/thumbnails.cljs +++ b/frontend/src/app/main/data/workspace/thumbnails.cljs @@ -17,6 +17,7 @@ [app.main.data.helpers :as dsh] [app.main.data.persistence :as-alias dps] [app.main.data.workspace.notifications :as-alias wnt] + [app.main.data.workspace.pages :as-alias dwpg] [app.main.rasterizer :as thr] [app.main.refs :as refs] [app.main.render :as render] @@ -254,7 +255,7 @@ (let [stopper-s (rx/filter (fn [event] (as-> (ptk/type event) type - (or (= :app.main.data.workspace/finalize-page type) + (or (= ::dwpg/finalize-page type) (= ::watch-state-changes type)))) stream)