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

Side by Side Diff: chrome/browser/resources/options/autofill_options_list.js

Issue 819193003: Fix list focus after tab key in chrome://settings/autofillEditAddress page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reviewer comments on patch set 5. Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options.autofillOptions', function() { 5 cr.define('options.autofillOptions', function() {
6 /** @const */ var DeletableItem = options.DeletableItem; 6 /** @const */ var DeletableItem = options.DeletableItem;
7 /** @const */ var DeletableItemList = options.DeletableItemList; 7 /** @const */ var DeletableItemList = options.DeletableItemList;
8 /** @const */ var InlineEditableItem = options.InlineEditableItem; 8 /** @const */ var InlineEditableItem = options.InlineEditableItem;
9 /** @const */ var InlineEditableItemList = options.InlineEditableItemList; 9 /** @const */ var InlineEditableItemList = options.InlineEditableItemList;
10 10
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 return; 201 return;
202 } 202 }
203 203
204 var entries = this.list.dataModel.slice(); 204 var entries = this.list.dataModel.slice();
205 if (this.valueIsNonEmpty_(value) && 205 if (this.valueIsNonEmpty_(value) &&
206 !entries.some(this.valuesAreEqual_.bind(this, value))) { 206 !entries.some(this.valuesAreEqual_.bind(this, value))) {
207 // Update with new value. 207 // Update with new value.
208 if (this.isPlaceholder) { 208 if (this.isPlaceholder) {
209 // It is important that updateIndex is done before validateAndSave. 209 // It is important that updateIndex is done before validateAndSave.
210 // Otherwise we can not be sure about AddRow index. 210 // Otherwise we can not be sure about AddRow index.
211 this.list.dataModel.updateIndex(i); 211 this.list.ignoreChangeEvents(function() {
212 this.list.dataModel.updateIndex(i);
213 }.bind(this));
212 this.list.validateAndSave(i, 0, value); 214 this.list.validateAndSave(i, 0, value);
213 } else { 215 } else {
214 this.list.validateAndSave(i, 1, value); 216 this.list.validateAndSave(i, 1, value);
215 } 217 }
216 } else { 218 } else {
217 // Reject empty values and duplicates. 219 // Reject empty values and duplicates.
218 if (!this.isPlaceholder) 220 if (!this.isPlaceholder) {
219 this.list.dataModel.splice(i, 1); 221 this.list.ignoreChangeEvents(function() {
220 else 222 this.list.dataModel.splice(i, 1);
223 }.bind(this));
224 this.list.selectIndexWithoutFocusing(i);
225 } else {
221 this.clearValue_(); 226 this.clearValue_();
227 }
222 } 228 }
223 }, 229 },
224 }; 230 };
225 231
226 /** 232 /**
227 * Creates a new name value list item. 233 * Creates a new name value list item.
228 * @param {options.autofillOptions.AutofillNameValuesList} list The parent 234 * @param {options.autofillOptions.AutofillNameValuesList} list The parent
229 * list of this item. 235 * list of this item.
230 * @param {Array.<string>} entry An array of [first, middle, last] names. 236 * @param {Array.<string>} entry An array of [first, middle, last] names.
231 * @constructor 237 * @constructor
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 }, 441 },
436 442
437 /** 443 /**
438 * Called when a new list item should be validated; subclasses are 444 * Called when a new list item should be validated; subclasses are
439 * responsible for implementing if validation is required. 445 * responsible for implementing if validation is required.
440 * @param {number} index The index of the item that was inserted or changed. 446 * @param {number} index The index of the item that was inserted or changed.
441 * @param {number} remove The number items to remove. 447 * @param {number} remove The number items to remove.
442 * @param {string} value The value of the item to insert. 448 * @param {string} value The value of the item to insert.
443 */ 449 */
444 validateAndSave: function(index, remove, value) { 450 validateAndSave: function(index, remove, value) {
445 this.dataModel.splice(index, remove, value); 451 this.ignoreChangeEvents(function() {
452 this.dataModel.splice(index, remove, value);
453 }.bind(this));
454 this.selectIndexWithoutFocusing(index);
446 }, 455 },
447 }; 456 };
448 457
449 /** 458 /**
450 * Create a new value list for phone number validation. 459 * Create a new value list for phone number validation.
451 * @constructor 460 * @constructor
452 * @extends {options.autofillOptions.AutofillValuesList} 461 * @extends {options.autofillOptions.AutofillValuesList}
453 */ 462 */
454 var AutofillNameValuesList = cr.ui.define('list'); 463 var AutofillNameValuesList = cr.ui.define('list');
455 464
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 * This should be called when a reply of chrome.send('validatePhoneNumbers') 515 * This should be called when a reply of chrome.send('validatePhoneNumbers')
507 * is received. 516 * is received.
508 */ 517 */
509 didReceiveValidationResult: function() { 518 didReceiveValidationResult: function() {
510 this.validationRequests_--; 519 this.validationRequests_--;
511 assert(this.validationRequests_ >= 0); 520 assert(this.validationRequests_ >= 0);
512 if (this.validationRequests_ <= 0) { 521 if (this.validationRequests_ <= 0) {
513 while (this.validationPromiseResolvers_.length) { 522 while (this.validationPromiseResolvers_.length) {
514 this.validationPromiseResolvers_.pop()(); 523 this.validationPromiseResolvers_.pop()();
515 } 524 }
516 // List has been repopulated. Focus the placeholder.
517 this.focusPlaceholder();
518 } 525 }
519 }, 526 },
520 527
521 /** 528 /**
522 * Returns a Promise which is fulfilled when all of validation requests are 529 * Returns a Promise which is fulfilled when all of validation requests are
523 * completed. 530 * completed.
524 * @return {!Promise} A promise. 531 * @return {!Promise} A promise.
525 */ 532 */
526 doneValidating: function() { 533 doneValidating: function() {
527 if (this.validationRequests_ <= 0) 534 if (this.validationRequests_ <= 0)
(...skipping 10 matching lines...) Expand all
538 CreditCardListItem: CreditCardListItem, 545 CreditCardListItem: CreditCardListItem,
539 ValuesListItem: ValuesListItem, 546 ValuesListItem: ValuesListItem,
540 NameListItem: NameListItem, 547 NameListItem: NameListItem,
541 AutofillAddressList: AutofillAddressList, 548 AutofillAddressList: AutofillAddressList,
542 AutofillCreditCardList: AutofillCreditCardList, 549 AutofillCreditCardList: AutofillCreditCardList,
543 AutofillValuesList: AutofillValuesList, 550 AutofillValuesList: AutofillValuesList,
544 AutofillNameValuesList: AutofillNameValuesList, 551 AutofillNameValuesList: AutofillNameValuesList,
545 AutofillPhoneValuesList: AutofillPhoneValuesList, 552 AutofillPhoneValuesList: AutofillPhoneValuesList,
546 }; 553 };
547 }); 554 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698