Merge "Suppress keyboard shortcuts while some elements are in focus"

This commit is contained in:
Dave Borowitz 2015-12-04 00:35:14 +00:00 committed by Gerrit Code Review
commit 93d98113f6
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

@ -221,6 +221,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">