[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) <aab@odoo.com>
This commit is contained in:
committed by
Aaron Bohy
parent
65513ef3f9
commit
97cd3c98cd
@@ -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';
|
||||
|
||||
@@ -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: `<tree editable="bottom">
|
||||
<field name="int_field" widget="handle" />
|
||||
<field name="foo" />
|
||||
</tree>`,
|
||||
viewOptions: {
|
||||
action: {
|
||||
help: '<p class="hello">click to add a foo</p>'
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// 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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user