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

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: Remove a couple log statements and add a comment. Created 5 years, 10 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 return; 203 return;
204 } 204 }
205 205
206 var entries = this.list.dataModel.slice(); 206 var entries = this.list.dataModel.slice();
207 if (this.valueIsNonEmpty_(value) && 207 if (this.valueIsNonEmpty_(value) &&
208 !entries.some(this.valuesAreEqual_.bind(this, value))) { 208 !entries.some(this.valuesAreEqual_.bind(this, value))) {
209 // Update with new value. 209 // Update with new value.
210 if (this.isPlaceholder) { 210 if (this.isPlaceholder) {
211 // It is important that updateIndex is done before validateAndSave. 211 // It is important that updateIndex is done before validateAndSave.
212 // Otherwise we can not be sure about AddRow index. 212 // Otherwise we can not be sure about AddRow index.
213 this.list.dataModel.updateIndex(i); 213 this.list.ignoreChangeEvents(function() {
214 this.list.dataModel.updateIndex(i);
215 }.bind(this));
214 this.list.validateAndSave(i, 0, value); 216 this.list.validateAndSave(i, 0, value);
215 } else { 217 } else {
216 this.list.validateAndSave(i, 1, value); 218 this.list.validateAndSave(i, 1, value);
217 } 219 }
218 } else { 220 } else {
219 // Reject empty values and duplicates. 221 // Reject empty values and duplicates.
220 if (!this.isPlaceholder) 222 if (!this.isPlaceholder) {
221 this.list.dataModel.splice(i, 1); 223 this.list.ignoreChangeEvents(function() {
222 else 224 this.list.dataModel.splice(i, 1);
225 }.bind(this));
226 this.list.selectIndexWithoutFocusing(i);
227 } else {
223 this.clearValue_(); 228 this.clearValue_();
229 }
224 } 230 }
225 }, 231 },
226 }; 232 };
227 233
228 /** 234 /**
229 * Creates a new name value list item. 235 * Creates a new name value list item.
230 * @param {options.autofillOptions.AutofillNameValuesList} list The parent 236 * @param {options.autofillOptions.AutofillNameValuesList} list The parent
231 * list of this item. 237 * list of this item.
232 * @param {Array.<string>} entry An array of [first, middle, last] names. 238 * @param {Array.<string>} entry An array of [first, middle, last] names.
233 * @constructor 239 * @constructor
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 }, 443 },
438 444
439 /** 445 /**
440 * Called when a new list item should be validated; subclasses are 446 * Called when a new list item should be validated; subclasses are
441 * responsible for implementing if validation is required. 447 * responsible for implementing if validation is required.
442 * @param {number} index The index of the item that was inserted or changed. 448 * @param {number} index The index of the item that was inserted or changed.
443 * @param {number} remove The number items to remove. 449 * @param {number} remove The number items to remove.
444 * @param {string} value The value of the item to insert. 450 * @param {string} value The value of the item to insert.
445 */ 451 */
446 validateAndSave: function(index, remove, value) { 452 validateAndSave: function(index, remove, value) {
447 this.dataModel.splice(index, remove, value); 453 this.ignoreChangeEvents(function() {
454 this.dataModel.splice(index, remove, value);
455 }.bind(this));
456 this.selectIndexWithoutFocusing(index);
448 }, 457 },
449 }; 458 };
450 459
451 /** 460 /**
452 * Create a new value list for phone number validation. 461 * Create a new value list for phone number validation.
453 * @constructor 462 * @constructor
454 * @extends {options.autofillOptions.AutofillValuesList} 463 * @extends {options.autofillOptions.AutofillValuesList}
455 */ 464 */
456 var AutofillNameValuesList = cr.ui.define('list'); 465 var AutofillNameValuesList = cr.ui.define('list');
457 466
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 * This should be called when a reply of chrome.send('validatePhoneNumbers') 517 * This should be called when a reply of chrome.send('validatePhoneNumbers')
509 * is received. 518 * is received.
510 */ 519 */
511 didReceiveValidationResult: function() { 520 didReceiveValidationResult: function() {
512 this.validationRequests_--; 521 this.validationRequests_--;
513 assert(this.validationRequests_ >= 0); 522 assert(this.validationRequests_ >= 0);
514 if (this.validationRequests_ <= 0) { 523 if (this.validationRequests_ <= 0) {
515 while (this.validationPromiseResolvers_.length) { 524 while (this.validationPromiseResolvers_.length) {
516 this.validationPromiseResolvers_.pop()(); 525 this.validationPromiseResolvers_.pop()();
517 } 526 }
518 // List has been repopulated. Focus the placeholder.
519 this.focusPlaceholder();
520 } 527 }
521 }, 528 },
522 529
523 /** 530 /**
524 * Returns a Promise which is fulfilled when all of validation requests are 531 * Returns a Promise which is fulfilled when all of validation requests are
525 * completed. 532 * completed.
526 * @return {!Promise} A promise. 533 * @return {!Promise} A promise.
527 */ 534 */
528 doneValidating: function() { 535 doneValidating: function() {
529 if (this.validationRequests_ <= 0) 536 if (this.validationRequests_ <= 0)
(...skipping 10 matching lines...) Expand all
540 CreditCardListItem: CreditCardListItem, 547 CreditCardListItem: CreditCardListItem,
541 ValuesListItem: ValuesListItem, 548 ValuesListItem: ValuesListItem,
542 NameListItem: NameListItem, 549 NameListItem: NameListItem,
543 AutofillAddressList: AutofillAddressList, 550 AutofillAddressList: AutofillAddressList,
544 AutofillCreditCardList: AutofillCreditCardList, 551 AutofillCreditCardList: AutofillCreditCardList,
545 AutofillValuesList: AutofillValuesList, 552 AutofillValuesList: AutofillValuesList,
546 AutofillNameValuesList: AutofillNameValuesList, 553 AutofillNameValuesList: AutofillNameValuesList,
547 AutofillPhoneValuesList: AutofillPhoneValuesList, 554 AutofillPhoneValuesList: AutofillPhoneValuesList,
548 }; 555 };
549 }); 556 });
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_uitest_util.cc ('k') | chrome/browser/resources/options/inline_editable_list.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698