Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1976 from matrix-org/t3chguy/ctrl-k_enter
Browse files Browse the repository at this point in the history
implement `hitting enter after Ctrl-K should switch to the first result`
  • Loading branch information
t3chguy authored Jun 16, 2018
2 parents a25cdb6 + 1afdb0e commit 477cb56
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/components/structures/LeftPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ var LeftPanel = React.createClass({
this._onMoveFocus(false);
handled = true;
break;
case KeyCode.ENTER:
this._onMoveFocus(false);
if (this.focusedElement) {
this.focusedElement.click();
}
handled = true;
break;
}

if (handled) {
Expand All @@ -102,37 +109,33 @@ var LeftPanel = React.createClass({
},

_onMoveFocus: function(up) {
var 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;

var descending = false; // are we currently descending or ascending through the DOM tree?
var classes;
let descending = false; // are we currently descending or ascending through the DOM tree?
let classes;

do {
var child = up ? element.lastElementChild : element.firstElementChild;
var sibling = up ? element.previousElementSibling : element.nextElementSibling;
const child = up ? element.lastElementChild : element.firstElementChild;
const sibling = up ? element.previousElementSibling : element.nextElementSibling;

if (descending) {
if (child) {
element = child;
}
else if (sibling) {
} else if (sibling) {
element = sibling;
}
else {
} else {
descending = false;
element = element.parentElement;
}
}
else {
} else {
if (sibling) {
element = sibling;
descending = true;
}
else {
} else {
element = element.parentElement;
}
}
Expand All @@ -144,8 +147,7 @@ var LeftPanel = React.createClass({
descending = true;
}
}

} while(element && !(
} while (element && !(
classes.contains("mx_RoomTile") ||
classes.contains("mx_SearchBox_search") ||
classes.contains("mx_RoomSubList_ellipsis")));
Expand Down

0 comments on commit 477cb56

Please sign in to comment.