Only preventDefault when a kb shortcut is triggered

Otherwise when a popup was shown, it will eat all keyboard
events.

Change-Id: Ia6fdada050a50075ed3a93e3180234c05baff9b7
This commit is contained in:
Andrew Bonventre 2016-01-14 10:41:04 -05:00 committed by Dave Borowitz
parent e4f06b3d95
commit 906471f1f7
4 changed files with 11 additions and 3 deletions

View File

@ -168,15 +168,18 @@ limitations under the License.
});
switch(e.keyCode) {
case 74: // 'j'
e.preventDefault();
if (this.selectedIndex == len - 1) { return; }
this.selectedIndex += 1;
break;
case 75: // 'k'
e.preventDefault();
if (this.selectedIndex == 0) { return; }
this.selectedIndex -= 1;
break;
case 79: // 'o'
case 13: // 'enter'
e.preventDefault();
page.show(this._changeURLForIndex(this.selectedIndex));
break;
}

View File

@ -172,13 +172,16 @@ limitations under the License.
switch(e.keyCode) {
case 219: // '['
e.preventDefault();
this._navToFile(this._fileList, -1);
break;
case 221: // ']'
e.preventDefault();
this._navToFile(this._fileList, 1);
break;
case 85: // 'u'
if (this._changeNum) {
e.preventDefault();
page.show(this._computeChangePath(this._changeNum));
}
break;

View File

@ -365,20 +365,22 @@ limitations under the License.
return;
}
e.preventDefault();
switch (e.keyCode) {
case 38: // 'up':
e.preventDefault();
this._selectedIndex = Math.max(this._selectedIndex - 1, 0);
break;
case 40: // 'down'
e.preventDefault();
this._selectedIndex = Math.min(this._selectedIndex + 1,
this._autocompleteData.length - 1);
break;
case 27: // 'esc'
e.preventDefault();
this._hideAutocomplete = true;
break;
case 13: // 'enter'
e.preventDefault();
this._sendAddRequest();
break;
}

View File

@ -101,9 +101,9 @@ limitations under the License.
_handleKey: function(e) {
if (util.shouldSupressKeyboardShortcut(e)) { return; }
e.preventDefault();
switch(e.keyCode) {
case 191: // '/'
e.preventDefault();
var s = this.$.searchInput;
s.focus();
s.setSelectionRange(0, s.value.length);