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

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

Issue 7565021: Options: Focus the placeholder input element if an item was added through the (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698