Chromium Code Reviews| Index: chrome/browser/resources/options/password_manager.js |
| diff --git a/chrome/browser/resources/options/password_manager.js b/chrome/browser/resources/options/password_manager.js |
| index 6263595fdd0e34b1deb478c70e4a59f54657b2b1..108b5ed3795df2f98dd6e6d3576363979bd4ba48 100644 |
| --- a/chrome/browser/resources/options/password_manager.js |
| +++ b/chrome/browser/resources/options/password_manager.js |
| @@ -160,14 +160,22 @@ cr.define('options', function() { |
| }, |
| /** |
| - * Updates the visibility of the list and empty list placeholder. |
| + * Updates the list with the given entries and updates the visibility of the |
| + * list and empty list placeholder. |
| * @param {!cr.ui.List} list The list to toggle visilibility for. |
| + * @param {!Array} entries The list of entries. |
| */ |
| - updateListVisibility_: function(list) { |
| - var empty = list.dataModel.length == 0; |
| + updateListAndVisibility_: function(list, entries) { |
| + // Since the dataModel setter behaves lazily, the visibility needs to be |
| + // updated before the list itself. Otherwise, there will be no visible |
| + // effect when the list transitions from a hidden to a visible state. This |
| + // is because the setter would realize that the list is hidden and would |
| + // not render its new entries (http://crbug.com/672869). |
| + var empty = entries.length == 0; |
| var listPlaceHolderID = list.id + '-empty-placeholder'; |
| list.hidden = empty; |
| $(listPlaceHolderID).hidden = !empty; |
| + list.dataModel = new ArrayDataModel(entries); |
| }, |
| /** |
| @@ -245,8 +253,7 @@ cr.define('options', function() { |
| }; |
| entries = entries.filter(filter); |
| } |
| - this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); |
| - this.updateListVisibility_(this.savedPasswordsList_); |
| + this.updateListAndVisibility_(this.savedPasswordsList_, entries); |
|
kolos1
2016/12/12 13:05:10
To prevent closure compilation error, we could add
|
| // updateOriginsEliding_ should be called after updateListVisibility_, |
| // otherwise updateOrigins... might be not able to read width of elements. |
| this.updateOriginsEliding_(this.savedPasswordsList_); |
| @@ -258,8 +265,7 @@ cr.define('options', function() { |
| * @param {!Array} entries The list of password exception data. |
| */ |
| setPasswordExceptionsList_: function(entries) { |
| - this.passwordExceptionsList_.dataModel = new ArrayDataModel(entries); |
| - this.updateListVisibility_(this.passwordExceptionsList_); |
| + this.updateListAndVisibility_(this.passwordExceptionsList_, entries); |
| // updateOriginsEliding_ should be called after updateListVisibility_, |
| // otherwise updateOrigins... might be not able to read width of elements. |
| this.updateOriginsEliding_(this.passwordExceptionsList_); |