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:
parent
0601fc74f8
commit
64c2ff6f2c
@ -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':
|
||||
|
@ -213,6 +213,8 @@ limitations under the License.
|
||||
},
|
||||
|
||||
_handleKey: function(e) {
|
||||
if (util.shouldSupressKeyboardShortcut(e)) { return; }
|
||||
|
||||
switch(e.detail.combo) {
|
||||
case 'a':
|
||||
this._showReplyField();
|
||||
|
@ -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);
|
||||
|
@ -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';
|
||||
};
|
||||
|
@ -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">
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user