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

Unified Diff: chrome/browser/resources/options/autofill_options_list.js

Issue 7903001: Improve Tab-key navigation for editing Autofill addresses and credit cards. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: De-nitting Created 9 years, 3 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/options/autofill_options_list.js
diff --git a/chrome/browser/resources/options/autofill_options_list.js b/chrome/browser/resources/options/autofill_options_list.js
index dd80600a163e428f4852a95ce4214dbfd340d99a..fe847e9c1e48cef8b9d84533a152744246041969 100644
--- a/chrome/browser/resources/options/autofill_options_list.js
+++ b/chrome/browser/resources/options/autofill_options_list.js
@@ -291,25 +291,6 @@ cr.define('options.autofillOptions', function() {
AutofillValuesList.prototype = {
__proto__: InlineEditableItemList.prototype,
- decorate: function() {
- InlineEditableItemList.prototype.decorate.call(this);
-
- var self = this;
- function handleBlur(e) {
- // When the blur event happens we do not know who is getting focus so we
- // delay this a bit until we know if the new focus node is outside the
- // list.
- var doc = e.target.ownerDocument;
- window.setTimeout(function() {
- var activeElement = doc.activeElement;
- if (!self.contains(activeElement))
- self.selectionModel.unselectAll();
- }, 50);
- }
-
- this.addEventListener('blur', handleBlur, true);
- },
-
/** @inheritDoc */
createItem: function(entry) {
if (entry != null)
@@ -329,6 +310,34 @@ cr.define('options.autofillOptions', function() {
},
/**
+ * Called when the list hierarchy as a whole loses or gains focus.
+ * If the list was focused in response to a mouse click, call into the
+ * superclass's implementation. If the list was focused in response to a
+ * keyboard navigation, focus the first item.
+ * If the list loses focus, unselect all the elements.
+ * @param {Event} e The change event.
+ * @private
+ */
+ handleListFocusChange_: function(e) {
+ // We check to see whether there is a selected item as a proxy for
+ // distinguishing between mouse- and keyboard-originated focus events.
+ var selectedItem = this.selectedItem;
+ if (selectedItem)
+ InlineEditableItemList.prototype.handleListFocusChange_.call(this, e);
+
+ if (!e.newValue) {
+ // When the list loses focus, unselect all the elements.
+ this.selectionModel.unselectAll();
+ } else {
+ // When the list gains focus, select the first item if nothing else is
+ // selected.
+ var firstItem = this.getListItemByIndex(0);
+ if (!selectedItem && firstItem && e.newValue)
+ firstItem.handleFocus_();
+ }
+ },
+
+ /**
* Called when a new list item should be validated; subclasses are
* responsible for implementing if validation is required.
* @param {number} index The index of the item that was inserted or changed.

Powered by Google App Engine
This is Rietveld 408576698