0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-09 00:10:11 -05:00

Prevent unexpected alt? state persistence on window blur.

Caused by using `ctrl+alt` kind of shortcuts that makes keyboard-alt
stream registring the key pressed but on bluring the window (unfocus)
the key down is never arrived.
This commit is contained in:
Andrey Antukh 2020-11-26 09:32:04 +01:00 committed by Hirunatan
parent 29669b8b0f
commit 78a8d20e04
2 changed files with 15 additions and 5 deletions

View file

@ -101,13 +101,24 @@
(rx/subscribe-with ob sub)
sub))
(defonce window-blur
(->> (rx/from-event js/window "blur")
(rx/share)))
(defonce keyboard-alt
(let [sub (rx/behavior-subject nil)
ob (->> st/stream
(rx/filter keyboard-event?)
(rx/map :alt)
ob (->> (rx/merge
(->> st/stream
(rx/filter keyboard-event?)
(rx/map :alt))
;; Fix a situation caused by using `ctrl+alt` kind of shortcuts,
;; that makes keyboard-alt stream registring the key pressed but
;; on bluring the window (unfocus) the key down is never arrived.
(->> window-blur
(rx/map (constantly false))))
(rx/dedupe))]
(rx/subscribe-with ob sub)
(rx/subscribe-with ob sub)
sub))
(defn mouse-position-deltas

View file

@ -86,7 +86,6 @@
(geom/translate-to-frame frame))
opts #js {:shape shape
:frame frame}
alt? (mf/use-state false)
on-mouse-enter (use-mouse-enter shape)
on-mouse-leave (use-mouse-leave shape)