Suppress keyboard shortcuts while some elements are in focus

Otherwise you could trigger them by typing the appropriate
shortcut while inside the search bar, for example.

Change-Id: I0ebc3f9235814faac19ec364f185386d8e496f04
This commit is contained in:
Andrew Bonventre 2015-12-02 18:02:04 -05:00
parent 0601fc74f8
commit 64c2ff6f2c
6 changed files with 17 additions and 0 deletions

View File

@ -84,6 +84,8 @@ limitations under the License.
},
_handleKey: function(e) {
if (util.shouldSupressKeyboardShortcut(e)) { return; }
var len = (this.changes && this.changes.length) || 0;
switch(e.detail.combo) {
case 'j':

View File

@ -213,6 +213,8 @@ limitations under the License.
},
_handleKey: function(e) {
if (util.shouldSupressKeyboardShortcut(e)) { return; }
switch(e.detail.combo) {
case 'a':
this._showReplyField();

View File

@ -314,6 +314,8 @@ limitations under the License.
},
_handleKey: function(e) {
if (util.shouldSupressKeyboardShortcut(e)) { return; }
switch(e.detail.combo) {
case '[':
this._navToFile(this._fileList, -1);

View File

@ -38,3 +38,12 @@ util.escapeHTML = function(str) {
return util.htmlEntityMap[s];
});
};
util.shouldSupressKeyboardShortcut = function(e) {
var target = e.detail.keyboardEvent.target;
return target.tagName == 'INPUT' ||
target.tagName == 'TEXTAREA' ||
target.tagName == 'SELECT' ||
target.tagName == 'BUTTON' ||
target.tagName == 'A';
};

View File

@ -22,6 +22,7 @@ limitations under the License.
<script src="../../bower_components/web-component-tester/browser.js"></script>
<script src="../../bower_components/page/page.js"></script>
<script src="../scripts/fake-app.js"></script>
<script src="../scripts/util.js"></script>
<link rel="import" href="../../bower_components/iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="../elements/gr-change-list.html">

View File

@ -22,6 +22,7 @@ limitations under the License.
<script src="../../bower_components/web-component-tester/browser.js"></script>
<script src="../../bower_components/page/page.js"></script>
<script src="../scripts/changes.js"></script>
<script src="../scripts/util.js"></script>
<link rel="import" href="../../bower_components/iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="../elements/gr-change-view.html">