Chromium Code Reviews| Index: chrome/browser/resources/options/inline_editable_list.js |
| diff --git a/chrome/browser/resources/options/inline_editable_list.js b/chrome/browser/resources/options/inline_editable_list.js |
| index b762a1d6d4a1d9b4c850d1b69ad66f59e648e21c..ba27e3c911c7cf49d3e4a190bf0d2cf70be53bca 100644 |
| --- a/chrome/browser/resources/options/inline_editable_list.js |
| +++ b/chrome/browser/resources/options/inline_editable_list.js |
| @@ -151,6 +151,9 @@ cr.define('options', function() { |
| } else { |
| if (!this.editCancelled_ && this.hasBeenEdited && |
| this.currentInputIsValid) { |
| + if (this.isPlaceholder) |
| + this.parentNode.focusPlaceholder = true; |
| + |
| this.updateStaticValues_(); |
| cr.dispatchSimpleEvent(this, 'commitedit', true); |
| } else { |
| @@ -242,7 +245,19 @@ cr.define('options', function() { |
| if (!this.isPlaceholder) { |
| inputEl.setAttribute('displaymode', 'edit'); |
| inputEl.staticVersion = textEl; |
| + } else { |
| + // At this point |this| is not attached to the parent list yet, so give |
| + // a short timeout in order for the attachment to occurr. |
|
csilv
2011/08/04 00:14:35
typo: "occur"
James Hawkins
2011/08/04 01:06:05
Done.
|
| + var self = this; |
| + window.setTimeout(function() { |
| + var list = self.parentNode; |
| + if (list && list.focusPlaceholder) { |
| + self.parentNode.focusPlaceholder = false; |
|
csilv
2011/08/04 00:14:35
could this be simplified as:
list.focusPlacehold
James Hawkins
2011/08/04 01:06:05
Done.
|
| + inputEl.focus(); |
| + } |
| + }, 50); |
| } |
| + |
| inputEl.addEventListener('focus', this.handleFocus_.bind(this)); |
| container.appendChild(inputEl); |
| this.editFields_.push(inputEl); |
| @@ -361,6 +376,12 @@ cr.define('options', function() { |
| InlineEditableItemList.prototype = { |
| __proto__: DeletableItemList.prototype, |
| + /** |
| + * Focuses the input element of the placeholder if true. |
| + * @type {boolean} |
| + */ |
| + focusPlaceholder: false, |
| + |
| /** @inheritDoc */ |
| decorate: function() { |
| DeletableItemList.prototype.decorate.call(this); |