From 63540e102beaa996f78d633256c816c3cc763f12 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 23 Jan 2020 22:50:37 +0200 Subject: [PATCH] Ignore Alt+ keybinds when focused in chat input Fixes #3719 --- client/components/App.vue | 20 ++++++++++++++++++-- client/js/keybinds.js | 10 +++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/client/components/App.vue b/client/components/App.vue index cf1460e5..cd378127 100644 --- a/client/components/App.vue +++ b/client/components/App.vue @@ -71,11 +71,27 @@ export default { clearTimeout(this.dayChangeTimeout); }, methods: { - toggleSidebar() { + toggleSidebar(e) { + // Do not handle this keybind in the chat input because + // it can be used to type letters with umlauts + if (e.target.tagName === "TEXTAREA") { + return true; + } + this.$store.commit("toggleSidebar"); + + return false; }, - toggleUserList() { + toggleUserList(e) { + // Do not handle this keybind in the chat input because + // it can be used to type letters with umlauts + if (e.target.tagName === "TEXTAREA") { + return true; + } + this.$store.commit("toggleUserlist"); + + return false; }, msUntilNextDay() { // Compute how many milliseconds are remaining until the next day starts diff --git a/client/js/keybinds.js b/client/js/keybinds.js index 91f069ed..47fd3e87 100644 --- a/client/js/keybinds.js +++ b/client/js/keybinds.js @@ -71,7 +71,15 @@ Mousetrap.bind(["alt+shift+up", "alt+shift+down"], function(e, keys) { // Jump to the first window with a highlight in it, or the first with unread // activity if there are none with highlights. -Mousetrap.bind(["alt+a"], function() { +Mousetrap.bind(["alt+a"], function(e) { + // Do not handle this keybind in the chat input because + // it can be used to type letters with umlauts + // Normally this is not required, but since chat input has the "mousetrap" + // class for other keybinds to work, we need to add this check + if (e.target.tagName === "TEXTAREA") { + return true; + } + let targetChannel; outer_loop: for (const network of store.state.networks) {