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

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: 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 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_);
« 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