From 1ec0bb284a49e89fc44bdf724e82c2e119189922 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 4 Oct 2019 11:47:33 +0100 Subject: [PATCH] Limit Backspace-consuming workaround to just Slate, tidy Keyboard :) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/Keyboard.js | 3 +++ src/components/structures/LoggedInView.js | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Keyboard.js b/src/Keyboard.js index c7de04f454..5e350bcad5 100644 --- a/src/Keyboard.js +++ b/src/Keyboard.js @@ -66,7 +66,10 @@ export const Key = { End: "End", PAGE_UP: "PageUp", PAGE_DOWN: "PageDown", + BACKSPACE: "Backspace", BACKTICK: "`", + SPACE: " ", + ENTER: "Enter", K: "k", }; diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 66210e2f93..ce3d27c2f7 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -399,10 +399,11 @@ const LoggedInView = createReactClass({ ev.preventDefault(); } else if (!hasModifier) { const isClickShortcut = ev.target !== document.body && - (ev.key === "Space" || ev.key === "Enter"); + (ev.key === Key.SPACE || ev.key === Key.ENTER); // XXX: Remove after CIDER replaces Slate completely: https://github.com/vector-im/riot-web/issues/11036 - if (ev.key === "Backspace") { + // If using Slate, consume the Backspace without first focusing as it causes an implosion + if (ev.key === Key.BACKSPACE && !SettingsStore.getValue("useCiderComposer")) { ev.stopPropagation(); return; }