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

Unified Diff: ui/webui/resources/js/cr/ui/table.js

Issue 2745593003: Use actual client width of list excluding scroll bar for adjusting column widths.
Patch Set: Add comment to describe existing issue. Created 3 years, 9 months 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: ui/webui/resources/js/cr/ui/table.js
diff --git a/ui/webui/resources/js/cr/ui/table.js b/ui/webui/resources/js/cr/ui/table.js
index 9e28e4c752e2361270ae2a7e037db70ffea79ea0..ec50933e83ed06f3936590a28b93aa25c5b9fee5 100644
--- a/ui/webui/resources/js/cr/ui/table.js
+++ b/ui/webui/resources/js/cr/ui/table.js
@@ -192,7 +192,16 @@ cr.define('cr.ui', function() {
* Redraws the table.
*/
redraw: function() {
+ var widthBeforeUpdate = this.list_.clientWidth;
this.list_.redraw();
+ // When resizing the window, vertical scrollbar might appear/disappear
+ // based on the balance between the view size and # of items. This logic
+ // is placed here instead of resize() because clientWidth is updated
+ // after drawing.
+ if (this.list_.clientWidth != widthBeforeUpdate) {
+ this.normalizeColumns();
+ this.list_.redraw();
+ }
this.header_.redraw();
},
@@ -202,7 +211,15 @@ cr.define('cr.ui', function() {
},
endBatchUpdates: function() {
+ var widthBeforeUpdate = this.list_.clientWidth;
this.list_.endBatchUpdates();
+ // Update of the list content may change the client width of the list
+ // because vertical scrollbar might appear/disappear depending on the
+ // number of items.
+ if (this.list_.clientWidth != widthBeforeUpdate) {
+ this.normalizeColumns();
+ this.list_.redraw();
+ }
this.header_.endBatchUpdates();
},
@@ -361,7 +378,9 @@ cr.define('cr.ui', function() {
},
normalizeColumns: function() {
- this.columnModel.normalizeWidths(this.clientWidth);
+ // list_.clientWidth must be used here instead of this.clientWidth,
+ // because it can be narrower by the thickness of the vertical scrollbar.
+ this.columnModel.normalizeWidths(this.list_.clientWidth);
yamaguchi 2017/03/14 09:07:30 cr.ui.table.TableColumnModel.normalizeWidths only
}
};
« 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