Chromium Code Reviews| 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); |
| - }, |
|
Ilya Sherman
2011/09/15 04:10:39
This functionality is now in |handleListFocusChang
|
| - |
| /** @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) |
|
James Hawkins
2011/09/15 19:28:02
Is there nothing in |e| that gives us better data
Ilya Sherman
2011/09/15 20:39:01
Not that I could find. If you know of something,
|
| + InlineEditableItemList.prototype.handleListFocusChange_.call(this, e); |
| + |
| + if (!e.newValue) { |
| + // When the list loses focus, unselect all the elements. |
| + this.selectionModel.unselectAll(); |
|
James Hawkins
2011/09/15 19:28:02
Hmm. Why unselect? Blur doesn't unselect on other
Ilya Sherman
2011/09/15 20:39:01
I personally think blur should unselect *all* list
|
| + } 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. |