Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: remove unused focus listeners in keybindings
Andrew Bastin05294ac556d4
diff --git a/helpers/keybindings.ts b/helpers/keybindings.tsindex e3354e55f..4cf8d6cfb 100644--- a/helpers/keybindings.ts+++ b/helpers/keybindings.ts@@ -10,13 +10,6 @@ import { isDOMElement, isTypableElement } from "./utils/dom"*/let keybindingsEnabled = true-/**- * This variable keeps track whether the currently focused element on the document- * is something that accepts a keyboard input- * (this is to prevent single character shortcuts from firing while typing)- */-let focusNotTypable = true-/*** Alt is also regarded as macOS OPTION (⌥) key* Ctrl is also regarded as macOS COMMAND (⌘) key (NOTE: this differs from HTML Keyboard spec where COMMAND is Meta key!)@@ -62,35 +55,13 @@ export const bindings: {export function hookKeybindingsListener() {onMounted(() => {document.addEventListener("keydown", handleKeyDown)- document.addEventListener("focusin", handleFocusUpdate)- document.addEventListener("focusout", handleFocusUpdate)})onBeforeUnmount(() => {document.removeEventListener("keydown", handleKeyDown)- document.removeEventListener("focusin", handleFocusUpdate)- document.removeEventListener("focusout", handleFocusUpdate)})}-function handleFocusUpdate(ev: FocusEvent) {- const target = ev.target-- if (isDOMElement(target) && isTypableElement(target)) {- if (focusNotTypable) {- console.log(- "Single Char keybindings are disabled because typable element is having focus"- )- focusNotTypable = false- }- } else if (!focusNotTypable) {- console.log(- "Single Char keybindings are restored because typable element is no longer focused"- )- focusNotTypable = true- }-}-function handleKeyDown(ev: KeyboardEvent) {// Do not check keybinds if the mode is disabledif (!keybindingsEnabled) return