From 289adeb63f51a9af26b8f383ba80089aa7aa6d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Tue, 21 Aug 2018 16:13:33 +0200 Subject: [FIX] web: properly resize textarea when its value changes Before this commit, a textarea would not resize when its value changed if the event was different than "input" or "focus". This commit fixes it by also listening to the "change" event, and by triggering it at appropriate times. PR: #26430 Task: 1869469 --- .../web/static/tests/fields/basic_fields_tests.js | 36 ++++++++++++++++++++++ 1 file changed, 36 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 e1da69fe9c5..3e545ad1681 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1487,6 +1487,42 @@ QUnit.module('basic_fields', { list.destroy(); }); + QUnit.test('text fields in edit mode should resize on reset', function (assert) { + assert.expect(1); + + this.data.partner.fields.foo.type = 'text'; + + this.data.partner.onchanges = { + bar: function (obj) { + obj.foo = 'a\nb\nc\nd\ne\nf'; + }, + }; + + var form = createView({ + View: FormView, + model: 'partner', + data: this.data, + arch: '
' + + '' + + '' + + '', + res_id: 1, + }); + + // edit the form + // trigger a textarea reset (through onchange) by clicking the box + // then check there is no scroll bar + form.$buttons.find('.o_form_button_edit').click(); + + form.$('div[name="bar"] input').click(); + + var $textarea = form.$('textarea:first'); + assert.strictEqual($textarea.innerHeight(), $textarea[0].scrollHeight, + "textarea should not have a scroll bar"); + + form.destroy(); + }); + QUnit.test('text field translatable', function (assert) { assert.expect(3); -- cgit v1.2.3