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

Unified Diff: chrome/browser/resources/options/password_manager.js

Issue 2571443002: Fix bug when transitioning from an empty to a non-empty password list (Closed)
Patch Set: Rebase and inline assert Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 be0e8e3fd5b61eb0b593731597dd012a1fd0d0cf..28431ba885dc8aa24868ca8ed733726e68295a62 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);
},
/**
@@ -195,8 +205,7 @@ cr.define('options', function() {
};
entries = entries.filter(filter);
}
- this.savedPasswordsList_.dataModel = new ArrayDataModel(entries);
- this.updateListVisibility_(this.savedPasswordsList_);
+ this.updateListAndVisibility_(assert(this.savedPasswordsList_), entries);
},
/**
@@ -205,8 +214,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_);
+ this.updateListAndVisibility_(
+ assert(this.passwordExceptionsList_), entries);
},
/**
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698