From e8d300723f77528d69120d586aa3d42d9a0f0d23 Mon Sep 17 00:00:00 2001 From: Julien Mougenot Date: Mon, 14 Oct 2019 09:06:14 +0000 Subject: [FIX] web: list: recompute default values for columns when visible Before this commit, all the computation of the default widths for column headers was done before the list was attached to the DOM, meaning that no column was actually visible. This was a problem since columns that are meant to stay unseen were taken into account in the calculation of relative column widths. Now, the same algorithm runs once the columns are visible so that invisible columns can be properly excluded. fixes #38744 Task 2076721 X-original-commit: 4bf98b47898b075049975dfe597f0fb92c7c14d1 --- .../web/static/tests/fields/basic_fields_tests.js | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'addons/web/static/tests/fields/basic_fields_tests.js') diff --git a/addons/web/static/tests/fields/basic_fields_tests.js b/addons/web/static/tests/fields/basic_fields_tests.js index 92f2e163b99..7c9e84239e3 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1823,6 +1823,57 @@ QUnit.module('basic_fields', { form.destroy(); }); + QUnit.test('text fields should have correct height after onchange', async function (assert) { + assert.expect(2); + + const damnLongText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. + Donec est massa, gravida eget dapibus ac, eleifend eget libero. + Suspendisse feugiat sed massa eleifend vestibulum. Sed tincidunt + velit sed lacinia lacinia. Nunc in fermentum nunc. Vestibulum ante + ipsum primis in faucibus orci luctus et ultrices posuere cubilia + Curae; Nullam ut nisi a est ornare molestie non vulputate orci. + Nunc pharetra porta semper. Mauris dictum eu nulla a pulvinar. Duis + eleifend odio id ligula congue sollicitudin. Curabitur quis aliquet + nunc, ut aliquet enim. Suspendisse malesuada felis non metus + efficitur aliquet.`; + + this.data.partner.records[0].txt = damnLongText; + this.data.partner.records[0].bar = false; + this.data.partner.onchanges = { + bar: function (obj) { + obj.txt = damnLongText; + }, + }; + const form = await createView({ + arch: ` +
+ + + `, + data: this.data, + model: 'partner', + res_id: 1, + View: FormView, + viewOptions: { mode: 'edit' }, + }); + + const textarea = form.el.querySelector('textarea[name="txt"]'); + const initialHeight = textarea.offsetHeight; + + await testUtils.fields.editInput($(textarea), 'Short value'); + + assert.ok(textarea.offsetHeight < initialHeight, + "Textarea height should have shrank"); + + await testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input')); + await testUtils.dom.click(form.$('.o_field_boolean[name="bar"] input')); + + assert.strictEqual(textarea.offsetHeight, initialHeight, + "Textarea height should be reset"); + + form.destroy(); + }); + QUnit.test('text fields in editable list have correct height', async function (assert) { assert.expect(2); -- cgit v1.2.3