From 25f7c14f97a26a723a2aa8d9c8e09e151a62b135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Wed, 17 May 2023 13:53:22 +0200 Subject: [PATCH] :bug: Fix deactivation of show distances when alt-tab is used Alt key with a shape selected activates show-distances mode. If you press Alt+tab, in many window managers the window is switched, and thus the alt keydown event is sent to other app and does not reach Penpot. So, we need to deactivate the mode also on window blur. --- frontend/src/app/main/ui/workspace.cljs | 2 +- frontend/src/app/main/ui/workspace/viewport.cljs | 5 ++--- frontend/src/app/main/ui/workspace/viewport/hooks.cljs | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/main/ui/workspace.cljs b/frontend/src/app/main/ui/workspace.cljs index a09bb2aef..1c5b63bb2 100644 --- a/frontend/src/app/main/ui/workspace.cljs +++ b/frontend/src/app/main/ui/workspace.cljs @@ -149,7 +149,7 @@ (mf/use-effect (mf/deps focus-out) (fn [] - (let [keys [(events/listen globals/document EventType.FOCUSOUT focus-out)]] + (let [keys [(events/listen globals/window EventType.BLUR focus-out)]] #(doseq [key keys] (events/unlistenByKey key))))) diff --git a/frontend/src/app/main/ui/workspace/viewport.cljs b/frontend/src/app/main/ui/workspace/viewport.cljs index 3ac8484ee..86578c363 100644 --- a/frontend/src/app/main/ui/workspace/viewport.cljs +++ b/frontend/src/app/main/ui/workspace/viewport.cljs @@ -239,7 +239,7 @@ first-selected-shape (first selected-shapes) selecting-first-level-frame? (and one-selected-shape? - (cph/root-frame? first-selected-shape)) + (cph/root-frame? first-selected-shape)) offset-x (if selecting-first-level-frame? (:x first-selected-shape) @@ -591,5 +591,4 @@ [:& grid-layout/editor {:zoom zoom :objects base-objects - :shape (get base-objects edition)}]) - ]]])) + :shape (get base-objects edition)}])]]])) diff --git a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs index 228597d85..147b772dd 100644 --- a/frontend/src/app/main/ui/workspace/viewport/hooks.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/hooks.cljs @@ -173,8 +173,7 @@ (->> move-stream (rx/tap #(reset! last-point-ref %)) ;; When transforming shapes we stop querying the worker - (rx/merge-map query-point) - ))))] + (rx/merge-map query-point)))))] ;; Refresh the refs on a value change (mf/use-effect