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);