From 4bde0c08ad5c3aaa95630e5110b6c8672bda94a7 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 17 Jul 2019 16:53:12 +0200 Subject: [PATCH] make sure we don't break any A or BUTTON keyboard handling --- src/components/structures/LoggedInView.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 16618bb973..e3a99a42ca 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -374,12 +374,11 @@ const LoggedInView = React.createClass({ const focusedOnInputControl = targetTag === "INPUT" || targetTag === "TEXTAREA" || targetTag === "SELECT" || - ev.target.getAttribute("contenteditable"); - // we don't check for buttons that have focus here, - // because they should be using AccessibleButton which - // calls stopPropagation on space or enter keydown, so - // that keydown event would never get here. - if (!focusedOnInputControl) { + !!ev.target.getAttribute("contenteditable"); + const isClickShortcut = ev.target !== document.body && + (ev.key === "Space" || ev.key === "Enter"); + + if (!focusedOnInputControl && !isClickShortcut) { dis.dispatch({action: 'focus_composer'}, true); ev.stopPropagation(); // we should *not* preventDefault() here as