Index: chrome/browser/resources/options/autofill_edit_creditcard_overlay.js |
diff --git a/chrome/browser/resources/options/autofill_edit_creditcard_overlay.js b/chrome/browser/resources/options/autofill_edit_creditcard_overlay.js |
index 4458ecc17616bb2a1135f50a6f70d08b80928f07..ac2a404241b22ab98841e89513e6a6a835da9ecb 100644 |
--- a/chrome/browser/resources/options/autofill_edit_creditcard_overlay.js |
+++ b/chrome/browser/resources/options/autofill_edit_creditcard_overlay.js |
@@ -180,10 +180,17 @@ cr.define('options', function() { |
/** |
* Loads the credit card data from |creditCard|, sets the input fields based |
- * on this data and stores the GUID of the credit card. |
+ * on this data and stores the GUID of the credit card. If |creditCard| is |
+ * null, this is an "Add New" dialog. Focus the first field. |
* @private |
*/ |
loadCreditCard_: function(creditCard) { |
+ if (!creditCard) { |
+ // Adding a new card --- focus the first element. |
+ this.pageDiv.querySelector('input').focus(); |
+ return; |
+ } |
+ |
this.setInputFields_(creditCard); |
this.inputFieldChanged_(); |
this.guid_ = creditCard.guid; |