From e5430259e9721355d5f7f2f0eb4ec4add1a8ee4c Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 10 Jan 2022 18:18:07 +0100 Subject: [PATCH] :bug: Changing pages while comments activated will not close the panel --- CHANGES.md | 1 + frontend/src/app/main/data/workspace.cljs | 19 +++++++++++-------- .../src/app/main/data/workspace/comments.cljs | 8 +++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 497e4a110..8905d9746 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -44,6 +44,7 @@ - Right click over artboard name to open its menu [Taiga #1679](https://tree.taiga.io/project/penpot/issue/1679) - Make the default session cookue use SameSite=Lax instead of Strict (causes some issues in latest versions of Chrome). - Fix "open in new tab" on dashboard [Taiga #2235](https://tree.taiga.io/project/penpot/issue/2355) +- Changing pages while comments activated will not close the panel [#1350](https://github.com/penpot/penpot/issues/1350) - Fix navigate comments in right sidebar [Taiga #2163](https://tree.taiga.io/project/penpot/issue/2163) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 8146ef574..0be39e309 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -282,10 +282,13 @@ (let [local (-> (:workspace-local state) (dissoc :edition :edit-path - :selected))] - (-> state - (assoc-in [:workspace-cache page-id] local) - (dissoc :current-page-id :workspace-local :trimmed-page :workspace-drawing)))))) + :selected)) + exit-workspace? (not= :workspace (get-in state [:route :data :name]))] + (cond-> (assoc-in state [:workspace-cache page-id] local) + :always + (dissoc :current-page-id :workspace-local :trimmed-page) + exit-workspace? + (dissoc :workspace-drawing)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Workspace Page CRUD @@ -416,9 +419,9 @@ (-> local (assoc :vport size) (update :vbox (fn [vbox] - (-> vbox - (update :width #(/ % wprop)) - (update :height #(/ % hprop)))))))) + (-> vbox + (update :width #(/ % wprop)) + (update :height #(/ % hprop)))))))) (initialize [state local] (let [page-id (:current-page-id state) @@ -445,7 +448,7 @@ :y (+ (:y srect) (/ (- (:height srect) height) 2))))))) (setup [state local] - (if (and (:vbox local) (:vport local)) + (if (and (:vport local) (:vbox local)) (update* local) (initialize state local)))] diff --git a/frontend/src/app/main/data/workspace/comments.cljs b/frontend/src/app/main/data/workspace/comments.cljs index a064b0d0a..ede10867f 100644 --- a/frontend/src/app/main/data/workspace/comments.cljs +++ b/frontend/src/app/main/data/workspace/comments.cljs @@ -76,15 +76,13 @@ (update [_ state] (update state :workspace-local (fn [{:keys [vbox zoom] :as local}] - (let [pw (/ 50 zoom) - ph (/ 200 zoom) + (let [pw (/ 160 zoom) + ph (/ 160 zoom) nw (mth/round (- (/ (:width vbox) 2) pw)) nh (mth/round (- (/ (:height vbox) 2) ph)) nx (- (:x position) nw) ny (- (:y position) nh)] - - - (update local :vbox assoc :x nx :y ny))))))) + (update local :vbox assoc :x nx :y ny))))))) (defn navigate [thread]