Commit 2cfa31e6 authored by mtomasz@chromium.org's avatar mtomasz@chromium.org

Check if a command can be executed before executing it via a shortcut.

Commands are updated when focus is updated. This makes sense, when executing commands by pressing an ui element. However, when executing a command via a shortcut, we may execute it while it shouldn't be allowed to be executed. This patch fixes it by updating the command's state (disabled/enabled) just before executing it via a shortcut.

TEST=Enter Files.app, select a file, then deselect a file, hit Delete button. A delete command should not be invoked.
BUG=174554


Review URL: https://chromiumcodereview.appspot.com/13532006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192514 0039d316-1c4b-4281-b951-d872f2087c98
parent 6175fc4e
...@@ -262,6 +262,11 @@ cr.define('cr.ui', function() { ...@@ -262,6 +262,11 @@ cr.define('cr.ui', function() {
// We do not want any other element to handle this. // We do not want any other element to handle this.
e.stopPropagation(); e.stopPropagation();
// 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(); command.execute();
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment