Skip to content

Commit

Permalink
Only emit global keyboard events when not in editable element
Browse files Browse the repository at this point in the history
  • Loading branch information
squidfunk committed Mar 26, 2020
1 parent c4820f9 commit c738110
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/assets/javascripts/integrations/keyboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ export function setupKeyboard(): Observable<Keyboard> {
mode: getToggle("search") ? "search" : "global",
...key
})),
filter(({ mode }) => {
if (mode === "global") {
const active = getActiveElement()
if (typeof active !== "undefined")
return !isSusceptibleToKeyboard(active)
}
return true
}),
share()
)

Expand Down Expand Up @@ -150,14 +158,7 @@ export function setupKeyboard(): Observable<Keyboard> {
/* Setup global keyboard handlers */
keyboard$
.pipe(
filter(({ mode }) => {
if (mode === "global") {
const active = getActiveElement()
if (typeof active !== "undefined")
return !isSusceptibleToKeyboard(active)
}
return false
}),
filter(({ mode }) => mode === "global"),
withLatestFrom(useComponent("search-query"))
)
.subscribe(([key, query]) => {
Expand Down

0 comments on commit c738110

Please sign in to comment.