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

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: Review fixes. 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..01aafedc26634652eea25cf0374a563b75ad123d 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 occur.
+ var self = this;
+ window.setTimeout(function() {
+ var list = self.parentNode;
+ if (list && list.focusPlaceholder) {
+ list.focusPlaceholder = false;
+ inputEl.focus();
+ }
+ }, 50);
}
+
inputEl.addEventListener('focus', this.handleFocus_.bind(this));
container.appendChild(inputEl);
this.editFields_.push(inputEl);
@@ -261,6 +276,7 @@ cr.define('options', function() {
var staticLabel = editFields[i].staticVersion;
if (!staticLabel && !this.isPlaceholder)
continue;
+
if (editFields[i].tagName == 'INPUT') {
editFields[i].value =
this.isPlaceholder ? '' : staticLabel.textContent;
@@ -283,6 +299,7 @@ cr.define('options', function() {
var staticLabel = editFields[i].staticVersion;
if (!staticLabel)
continue;
+
if (editFields[i].tagName == 'INPUT')
staticLabel.textContent = editFields[i].value;
// Add more tag types here as new createEditable* methods are added.
@@ -361,6 +378,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