Only emit global keyboard events when not in editable element

This commit is contained in:
squidfunk 2020-03-26 19:48:07 +01:00
parent c4820f9313
commit c738110391

View File

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