Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4813)

Unified Diff: chrome/browser/resources/md_bookmarks/command_manager.js

Issue 2885353002: MD Bookmarks: Prevent keyboard shortcuts when the toolbar/dialogs are focused (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/md_bookmarks/command_manager.js
diff --git a/chrome/browser/resources/md_bookmarks/command_manager.js b/chrome/browser/resources/md_bookmarks/command_manager.js
index 7dbf8d0761bdc5483eb2c99414124e2efad14d2a..027cf2bf09910cbc29cb174c1c798c8805211b7c 100644
--- a/chrome/browser/resources/md_bookmarks/command_manager.js
+++ b/chrome/browser/resources/md_bookmarks/command_manager.js
@@ -16,6 +16,13 @@ cr.define('bookmarks', function() {
],
properties: {
+ /**
+ * If set, this will restrict keyboard shortcuts to only execute when a
+ * child of this element (or <body>) is focused.
calamity 2017/05/19 04:09:27 This is a bit confusing. Is 'this element' the com
tsergeant 2017/06/01 03:17:05 Obsolete
+ * @type {?Element}
+ */
+ keyTarget: Object,
+
/** @private {!Array<Command>} */
menuCommands_: {
type: Array,
@@ -324,8 +331,11 @@ cr.define('bookmarks', function() {
*/
onKeydown_: function(e) {
var selection = this.getState().selection.items;
- // TODO(tsergeant): Prevent keyboard shortcuts when a dialog is open or
- // text field is focused.
+ if (this.keyTarget && e.path[0] != document.body &&
calamity 2017/05/19 04:09:27 Are there other exceptions that we need here? What
tsergeant 2017/06/01 03:17:05 Done, I think?
+ e.path.indexOf(this.keyTarget) == -1) {
+ return;
+ }
+
for (var commandName in this.shortcuts_) {
var shortcut = this.shortcuts_[commandName];
if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(

Powered by Google App Engine
This is Rietveld 408576698