Commit 4b7ac8c3 authored by jhawkins@chromium.org's avatar jhawkins@chromium.org

Options: Two fixes for Autofill lists.

* Don't update the model if no entry is committed.
* Don't focus the placeholder for AF lists, since it doesn't particularly make
  sense to add a second name right away.

BUG=92237
TEST=none

R=csilv@chromium.org

Review URL: http://codereview.chromium.org/7607027

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@96205 0039d316-1c4b-4281-b951-d872f2087c98
parent 79282efb
...@@ -169,7 +169,7 @@ cr.define('options.autofillOptions', function() { ...@@ -169,7 +169,7 @@ cr.define('options.autofillOptions', function() {
*/ */
onEditCommitted_: function(e) { onEditCommitted_: function(e) {
var i = this.list.items.indexOf(this); var i = this.list.items.indexOf(this);
if (i < 0 || i >= this.list.dataModel.length) if (i < 0 || i >= this.list.dataModel.length || !this.input.value.length)
return; return;
if (this.input.value && if (this.input.value &&
...@@ -180,7 +180,6 @@ cr.define('options.autofillOptions', function() { ...@@ -180,7 +180,6 @@ cr.define('options.autofillOptions', function() {
this.list.validateAndSave(i, 0, this.input.value); this.list.validateAndSave(i, 0, this.input.value);
} else { } else {
this.input.value = ''; this.input.value = '';
this.list.dataModel.updateIndex(i);
} }
}, },
}; };
...@@ -307,6 +306,11 @@ cr.define('options.autofillOptions', function() { ...@@ -307,6 +306,11 @@ cr.define('options.autofillOptions', function() {
this.dataModel.splice(index, 1); this.dataModel.splice(index, 1);
}, },
/** @inheritDoc */
shouldFocusPlaceholder: function() {
return false;
},
/** /**
* Called when a new list item should be validated; subclasses are * Called when a new list item should be validated; subclasses are
* responsible for implementing if validation is required. * responsible for implementing if validation is required.
......
...@@ -142,7 +142,7 @@ cr.define('options', function() { ...@@ -142,7 +142,7 @@ cr.define('options', function() {
if (focusElement) { if (focusElement) {
window.setTimeout(function() { window.setTimeout(function() {
// Make sure we are still in edit mode by the time we execute. // Make sure we are still in edit mode by the time we execute.
if (self.editing) { if (self.editing && self.focusPlaceholder) {
focusElement.focus(); focusElement.focus();
focusElement.select(); focusElement.select();
} }
...@@ -253,6 +253,7 @@ cr.define('options', function() { ...@@ -253,6 +253,7 @@ cr.define('options', function() {
var list = self.parentNode; var list = self.parentNode;
if (list && list.focusPlaceholder) { if (list && list.focusPlaceholder) {
list.focusPlaceholder = false; list.focusPlaceholder = false;
if (list.shouldFocusPlaceholder())
inputEl.focus(); inputEl.focus();
} }
}, 50); }, 50);
...@@ -407,6 +408,14 @@ cr.define('options', function() { ...@@ -407,6 +408,14 @@ cr.define('options', function() {
leadItem.editing = false; leadItem.editing = false;
} }
}, },
/**
* May be overridden by subclasses to disable focusing the placeholder.
* @return true if the placeholder element should be focused on edit commit.
*/
shouldFocusPlaceholder: function() {
return true;
},
}; };
// Export // Export
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment