From 97cd3c98cd7dc199ec1bd6de534d6a7202be7bbc Mon Sep 17 00:00:00 2001 From: Kaushalya Mandaliya Date: Wed, 19 Feb 2020 07:26:39 +0000 Subject: [PATCH] [FIX] web: list: set proper width for the handle widget Before this commit, when creating the first record in an editable list (displaying no content helper), the width of the handle widget cell was correct while the row was in edition, but it was reset to 0 as soon as the record was saved. There are two places where this issue occurred: Journal Groups (Accounting) and Ticket Type (Helpdesk). After this commit, proper width will be set for the handle widget in the editable listview on the first record creation. task-2166338 closes odoo/odoo#46846 X-original-commit: 28b06e78b4940d3b6feb23c77c7de3441a50c0dc Signed-off-by: Aaron Bohy (aab) --- .../js/views/list/list_editable_renderer.js | 2 +- addons/web/static/tests/views/list_tests.js | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) 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 358ef8afc37..8b4db487ac4 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 @@ -662,7 +662,7 @@ ListRenderer.include({ const table = this.el.getElementsByTagName('table')[0]; let columnWidths = this.columnWidths; - if (!columnWidths) { // no column widths to restore + if (!columnWidths || !columnWidths.length) { // no column widths to restore // Set table layout auto and remove inline style to make sure that css // rules apply (e.g. fixed width of record selector) table.style.tableLayout = 'auto'; diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index 1ff480fb0e1..19648bfb44b 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -1713,6 +1713,47 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('empty editable list with the handle widget and no content help', async function (assert) { + assert.expect(4); + + // no records for the foo model + this.data.foo.records = []; + + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: ` + + + `, + viewOptions: { + action: { + help: '

click to add a foo

' + } + }, + }); + + // as help is being provided in the action, table won't be rendered until a record exists + assert.containsNone(list, '.o_list_table', " there should not be any records in the view."); + assert.containsOnce(list, '.o_view_nocontent', "should have no content help"); + + // click on create button + await testUtils.dom.click(list.$('.o_list_button_add')); + const handleWidgetMinWidth = "33px"; + const handleWidgetHeader = list.$('thead > tr > th.o_handle_cell'); + assert.strictEqual(handleWidgetHeader.css('min-width'), handleWidgetMinWidth, + "While creating first record, min-width should be applied to handle widget."); + + // creating one record + await testUtils.fields.editInput(list.$("tr.o_selected_row input[name='foo']"), 'test_foo'); + await testUtils.dom.click(list.$('.o_list_button_save')); + assert.strictEqual(handleWidgetHeader.css('min-width'), handleWidgetMinWidth, + "After creation of the first record, min-width of the handle widget should remain as it is"); + + list.destroy(); + }); + QUnit.test('editable list: overflowing table', async function (assert) { assert.expect(1);