Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
pull/21833/head
Michael Telatynski 2020-07-03 14:49:25 +01:00
parent 47ee00ec5d
commit c8a93e9dd7
1 changed files with 5 additions and 13 deletions

View File

@ -166,20 +166,18 @@ export default class LeftPanel2 extends React.Component<IProps, IState> {
switch (ev.key) { switch (ev.key) {
case Key.ARROW_UP: case Key.ARROW_UP:
case Key.ARROW_DOWN: case Key.ARROW_DOWN:
this.onMoveFocus(ev, ev.key === Key.ARROW_UP); ev.stopPropagation();
ev.preventDefault();
this.onMoveFocus(ev.key === Key.ARROW_UP);
break; break;
} }
}; };
private onMoveFocus = (ev: React.KeyboardEvent, up: boolean) => { private onMoveFocus = (up: boolean) => {
let element = this.focusedElement; let element = this.focusedElement;
// unclear why this isn't needed
// var descending = (up == this.focusDirection) ? this.focusDescending : !this.focusDescending;
// this.focusDirection = up;
let descending = false; // are we currently descending or ascending through the DOM tree? let descending = false; // are we currently descending or ascending through the DOM tree?
let classes; let classes: DOMTokenList;
do { do {
const child = up ? element.lastElementChild : element.firstElementChild; const child = up ? element.lastElementChild : element.firstElementChild;
@ -212,14 +210,8 @@ export default class LeftPanel2 extends React.Component<IProps, IState> {
classes.contains("mx_RoomSearch_input"))); classes.contains("mx_RoomSearch_input")));
if (element) { if (element) {
ev.stopPropagation();
ev.preventDefault();
element.focus(); element.focus();
this.focusedElement = element; this.focusedElement = element;
} else {
// if navigation is via up/down arrow-keys, trap in the widget so it doesn't send to composer
ev.stopPropagation();
ev.preventDefault();
} }
}; };