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

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: Add a test Created 3 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/compiled_resources2.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 e2f84cd9f4501248710c8da247eb99e3decb0128..be258a32c7548144d7aca5cbc2fd02cb8618c576 100644
--- a/chrome/browser/resources/md_bookmarks/command_manager.js
+++ b/chrome/browser/resources/md_bookmarks/command_manager.js
@@ -217,6 +217,29 @@ cr.define('bookmarks', function() {
}
},
+ /**
+ * @param {Event} e
+ * @param {!Set<string>} itemIds
+ * @return {boolean} True if the event was handled, triggering a keyboard
+ * shortcut.
+ */
+ handleKeyEvent: function(e, itemIds) {
+ for (var commandName in this.shortcuts_) {
+ var shortcut = this.shortcuts_[commandName];
+ if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(
+ e, shortcut) &&
+ this.canExecute(commandName, itemIds)) {
+ this.handle(commandName, itemIds);
+
+ e.stopPropagation();
+ e.preventDefault();
+ return true;
+ }
+ }
+
+ return false;
+ },
+
////////////////////////////////////////////////////////////////////////////
// Private functions:
@@ -340,20 +363,8 @@ 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.
- for (var commandName in this.shortcuts_) {
- var shortcut = this.shortcuts_[commandName];
- if (Polymer.IronA11yKeysBehavior.keyboardEventMatchesKeys(
- e, shortcut) &&
- this.canExecute(commandName, selection)) {
- this.handle(commandName, selection);
-
- e.stopPropagation();
- e.preventDefault();
- return;
- }
- }
+ if (e.target == document.body)
+ this.handleKeyEvent(e, selection);
},
/**
« no previous file with comments | « no previous file | chrome/browser/resources/md_bookmarks/compiled_resources2.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698