Merge pull request #1976 from matrix-org/t3chguy/ctrl-k_enter
implement `hitting enter after Ctrl-K should switch to the first result`
This commit is contained in:
commit
477cb56591
1 changed files with 17 additions and 15 deletions
|
@ -93,6 +93,13 @@ var LeftPanel = React.createClass({
|
||||||
this._onMoveFocus(false);
|
this._onMoveFocus(false);
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
|
case KeyCode.ENTER:
|
||||||
|
this._onMoveFocus(false);
|
||||||
|
if (this.focusedElement) {
|
||||||
|
this.focusedElement.click();
|
||||||
|
}
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handled) {
|
if (handled) {
|
||||||
|
@ -102,37 +109,33 @@ var LeftPanel = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMoveFocus: function(up) {
|
_onMoveFocus: function(up) {
|
||||||
var element = this.focusedElement;
|
let element = this.focusedElement;
|
||||||
|
|
||||||
// unclear why this isn't needed
|
// unclear why this isn't needed
|
||||||
// var descending = (up == this.focusDirection) ? this.focusDescending : !this.focusDescending;
|
// var descending = (up == this.focusDirection) ? this.focusDescending : !this.focusDescending;
|
||||||
// this.focusDirection = up;
|
// this.focusDirection = up;
|
||||||
|
|
||||||
var 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?
|
||||||
var classes;
|
let classes;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
var child = up ? element.lastElementChild : element.firstElementChild;
|
const child = up ? element.lastElementChild : element.firstElementChild;
|
||||||
var sibling = up ? element.previousElementSibling : element.nextElementSibling;
|
const sibling = up ? element.previousElementSibling : element.nextElementSibling;
|
||||||
|
|
||||||
if (descending) {
|
if (descending) {
|
||||||
if (child) {
|
if (child) {
|
||||||
element = child;
|
element = child;
|
||||||
}
|
} else if (sibling) {
|
||||||
else if (sibling) {
|
|
||||||
element = sibling;
|
element = sibling;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
descending = false;
|
descending = false;
|
||||||
element = element.parentElement;
|
element = element.parentElement;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (sibling) {
|
if (sibling) {
|
||||||
element = sibling;
|
element = sibling;
|
||||||
descending = true;
|
descending = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
element = element.parentElement;
|
element = element.parentElement;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,8 +147,7 @@ var LeftPanel = React.createClass({
|
||||||
descending = true;
|
descending = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} while (element && !(
|
||||||
} while(element && !(
|
|
||||||
classes.contains("mx_RoomTile") ||
|
classes.contains("mx_RoomTile") ||
|
||||||
classes.contains("mx_SearchBox_search") ||
|
classes.contains("mx_SearchBox_search") ||
|
||||||
classes.contains("mx_RoomSubList_ellipsis")));
|
classes.contains("mx_RoomSubList_ellipsis")));
|
||||||
|
|
Loading…
Reference in a new issue