summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authormtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-29 11:19:11 +0000
committermtomasz@chromium.org <mtomasz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-29 11:19:11 +0000
commit6b353cf8992e4d29c90964ab12806ba3172ed873 (patch)
tree85dcbae77f0c429eebd412004b813099d4eb238c /ui
parenta2d03c0bb38954aab38933f881a7c2338732623a (diff)
downloadchromium_src-6b353cf8992e4d29c90964ab12806ba3172ed873.zip
chromium_src-6b353cf8992e4d29c90964ab12806ba3172ed873.tar.gz
chromium_src-6b353cf8992e4d29c90964ab12806ba3172ed873.tar.bz2
Fix handling commands when executed with a shortcut.
Before, commands were not executed if they were formerly disabled, and later a shortcut was fired. This was happening because command state (enabled/disabled) is checked when focus changes. This patch resolves this issue by rechecking if the command is enabled or disabled when firing a shortcut. TEST=browser_test:*KeyboardOperations* BUG=263703 R=nkostylev@chromium.org Review URL: https://codereview.chromium.org/21039003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@214174 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/webui/resources/js/cr/ui/command.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/ui/webui/resources/js/cr/ui/command.js b/ui/webui/resources/js/cr/ui/command.js
index 1723dd7..280503b 100644
--- a/ui/webui/resources/js/cr/ui/command.js
+++ b/ui/webui/resources/js/cr/ui/command.js
@@ -257,18 +257,19 @@ cr.define('cr.ui', function() {
target.ownerDocument.querySelectorAll('command'));
for (var i = 0, command; command = commands[i]; i++) {
- if (!command.disabled && command.matchesEvent(e)) {
- e.preventDefault();
- // We do not want any other element to handle this.
- e.stopPropagation();
-
+ if (command.matchesEvent(e)) {
// When invoking a command via a shortcut, we have to manually check
// if it can be executed, since focus might not have been changed
// what would have updated the command's state.
command.canExecuteChange();
- command.execute();
- return;
+ if (!command.disabled) {
+ e.preventDefault();
+ // We do not want any other element to handle this.
+ e.stopPropagation();
+ command.execute();
+ return;
+ }
}
}
}