[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
This commit is contained in:
Sébastien Theys
2018-08-22 11:51:30 +02:00
parent 4310b11df5
commit 289adeb63f
4 changed files with 64 additions and 3 deletions
@@ -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: '<form string="Partners">' +
'<field name="bar"/>' +
'<field name="foo"/>' +
'</form>',
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);