focus the composer in the body keydown handler if not other shortcuts apply

this allows the user to start typing a message even if the composer is not focused.
pull/21833/head
Bruno Windels 2019-07-15 18:12:45 +02:00
parent 380639516b
commit 4adea67eb3
1 changed files with 16 additions and 0 deletions

View File

@ -333,6 +333,22 @@ const LoggedInView = React.createClass({
if (handled) {
ev.stopPropagation();
ev.preventDefault();
} else {
const targetTag = ev.target.tagName;
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) {
dis.dispatch({action: 'focus_composer'}, true);
ev.stopPropagation();
// we should *not* preventDefault() here as
// that would prevent typing in the now-focussed composer
}
}
},