summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 22:24:06 +0000
committerstuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-23 22:24:06 +0000
commite86f32612126b3f9bf77a2e85113e27728680b1f (patch)
treeefef130a44d5b052f2738fcc205e573160eb2518 /chrome
parent9d9f1bb2aa1bd6db5e04e8ebd586f924d2532964 (diff)
downloadchromium_src-e86f32612126b3f9bf77a2e85113e27728680b1f.zip
chromium_src-e86f32612126b3f9bf77a2e85113e27728680b1f.tar.gz
chromium_src-e86f32612126b3f9bf77a2e85113e27728680b1f.tar.bz2
Don't always steal key events in WebUI lists
Allows input elements to have normal keyboard behavior when in WebUI lists. BUG=72467 TEST=Key commands should work normally for inputs and selects in WebUI lists (e.g., tabbed options) Review URL: http://codereview.chromium.org/6532097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75801 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/resources/shared/js/cr/ui/list_selection_controller.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/chrome/browser/resources/shared/js/cr/ui/list_selection_controller.js b/chrome/browser/resources/shared/js/cr/ui/list_selection_controller.js
index fa1f3c2..35101d1 100644
--- a/chrome/browser/resources/shared/js/cr/ui/list_selection_controller.js
+++ b/chrome/browser/resources/shared/js/cr/ui/list_selection_controller.js
@@ -180,6 +180,26 @@ cr.define('cr.ui', function() {
* @param {Event} e The keydown event.
*/
handleKeyDown: function(e) {
+ const SPACE_KEY_CODE = 32;
+ var tagName = e.target.tagName;
+ // If focus is in an input field of some kind, only handle navigation keys
+ // that aren't likely to conflict with input interaction (e.g., text
+ // editing, or changing the value of a checkbox or select).
+ if (tagName == 'INPUT') {
+ var inputType = e.target.type;
+ // Just protect space (for toggling) for checkbox and radio.
+ if (inputType == 'checkbox' || inputType == 'radio') {
+ if (e.keyCode == SPACE_KEY_CODE)
+ return;
+ // Protect all but the most basic navigation commands in anything else.
+ } else if (e.keyIdentifier != 'Up' && e.keyIdentifier != 'Down') {
+ return;
+ }
+ }
+ // Similarly, don't interfere with select element handling.
+ if (tagName == 'SELECT')
+ return;
+
var sm = this.selectionModel;
var newIndex = -1;
var leadIndex = sm.leadIndex;
@@ -194,7 +214,7 @@ cr.define('cr.ui', function() {
}
// Space
- if (e.keyCode == 32) {
+ if (e.keyCode == SPACE_KEY_CODE) {
if (leadIndex != -1) {
var selected = sm.getIndexSelected(leadIndex);
if (e.ctrlKey || !selected) {