mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 08:20:45 -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:
parent
29669b8b0f
commit
78a8d20e04
2 changed files with 15 additions and 5 deletions
|
@ -101,13 +101,24 @@
|
||||||
(rx/subscribe-with ob sub)
|
(rx/subscribe-with ob sub)
|
||||||
sub))
|
sub))
|
||||||
|
|
||||||
|
|
||||||
|
(defonce window-blur
|
||||||
|
(->> (rx/from-event js/window "blur")
|
||||||
|
(rx/share)))
|
||||||
|
|
||||||
(defonce keyboard-alt
|
(defonce keyboard-alt
|
||||||
(let [sub (rx/behavior-subject nil)
|
(let [sub (rx/behavior-subject nil)
|
||||||
ob (->> st/stream
|
ob (->> (rx/merge
|
||||||
(rx/filter keyboard-event?)
|
(->> st/stream
|
||||||
(rx/map :alt)
|
(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/dedupe))]
|
||||||
(rx/subscribe-with ob sub)
|
(rx/subscribe-with ob sub)
|
||||||
sub))
|
sub))
|
||||||
|
|
||||||
(defn mouse-position-deltas
|
(defn mouse-position-deltas
|
||||||
|
|
|
@ -86,7 +86,6 @@
|
||||||
(geom/translate-to-frame frame))
|
(geom/translate-to-frame frame))
|
||||||
opts #js {:shape shape
|
opts #js {:shape shape
|
||||||
:frame frame}
|
:frame frame}
|
||||||
alt? (mf/use-state false)
|
|
||||||
on-mouse-enter (use-mouse-enter shape)
|
on-mouse-enter (use-mouse-enter shape)
|
||||||
on-mouse-leave (use-mouse-leave shape)
|
on-mouse-leave (use-mouse-leave shape)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue