diff options
| author | Aaron Bohy <aab@odoo.com> | 2019-09-19 11:14:50 +0000 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-09-25 06:16:54 +0000 |
| commit | be222b795e0bc05989ae6ac8cc533cbee2e1458c (patch) | |
| tree | bd3642a6da7a281d1717bd193e752f024f3539bc /addons/web/static/src | |
| parent | 22d43f15401304262acf809032d7bf4c4f1c77d2 (diff) | |
[FIX] web: list: keep widths when editing records
Let's assume an editable list view with at least two rows. Before
this rev., the column widths were re-computed and frozen each time
a record was switched into 'edit' mode. As a consequence, if the
user clicked on a row, and then on another one, column widths might
slightly change.
Task 2068261
Diffstat (limited to 'addons/web/static/src')
| -rw-r--r-- | addons/web/static/src/js/views/list/list_editable_renderer.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js index f8ab5eebda3..eb64aebf855 100644 --- a/addons/web/static/src/js/views/list/list_editable_renderer.js +++ b/addons/web/static/src/js/views/list/list_editable_renderer.js @@ -527,9 +527,7 @@ ListRenderer.include({ // There are some cases where a record is added to an invisible list // e.g. set a quotation template with optionnal products if (params.keepWidths && this.$el.is(':visible')) { - this.columnWidths = this.$('thead th').toArray().map(function (th) { - return $(th).outerWidth(); - }); + this._storeColumnWidths(); } if (params.noRender) { // the state changed, but we won't do a re-rendering right now, so @@ -1228,6 +1226,10 @@ ListRenderer.include({ if (rowIndex === this.currentRow) { return Promise.resolve(); } + if (!this.columnWidths) { + // we don't want the column widths to change when selecting rows + this._storeColumnWidths(); + } this._freezeColumnWidths(); var recordId = this._getRecordID(rowIndex); // To select a row, the currently selected one must be unselected first @@ -1254,6 +1256,14 @@ ListRenderer.include({ }); }); }, + /** + * @private + */ + _storeColumnWidths: function () { + this.columnWidths = this.$('thead th').toArray().map(function (th) { + return $(th).outerWidth(); + }); + }, //-------------------------------------------------------------------------- // Handlers |
