Chromium Code Reviews| 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
|
| } |
| }; |