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..351e264ae52f1dc4e6c34ce425348286e5f2cbdd 100644 |
| --- a/chrome/browser/resources/options/password_manager.js |
| +++ b/chrome/browser/resources/options/password_manager.js |
| @@ -160,14 +160,24 @@ 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) { |
| + // Setting the dataModel results in a redraw of the viewport, which is why |
| + // the visibility needs to be updated first. Otherwise, redraw will not |
| + // render the updated entries when transitioning from a previously empty |
| + // list to a non-empty one. The attribute list.hidden would be true in |
| + // this case, resulting in |redraw()| not adding the new elements to the |
| + // viewport and thus showing a empty list to the user |
| + // (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 +255,8 @@ cr.define('options', function() { |
| }; |
| entries = entries.filter(filter); |
| } |
| - this.savedPasswordsList_.dataModel = new ArrayDataModel(entries); |
| - this.updateListVisibility_(this.savedPasswordsList_); |
| + assert(this.savedPasswordsList_ !== null); |
| + this.updateListAndVisibility_(this.savedPasswordsList_, entries); |
|
Dan Beam
2016/12/20 22:25:12
can you just wrap with assert(), as in:
this.upda
jdoerrie
2016/12/21 07:07:41
Done.
|
| // updateOriginsEliding_ should be called after updateListVisibility_, |
| // otherwise updateOrigins... might be not able to read width of elements. |
| this.updateOriginsEliding_(this.savedPasswordsList_); |
| @@ -258,8 +268,8 @@ 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_); |
| + assert(this.passwordExceptionsList_ !== null); |
| + 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_); |