[FIX] web: textarea do not resize properly

Current behaviour:
When clicking on a note containing
multi-line text, the textarea shrinks

Expected behaviour:
Note should show whole text

Steps to reproduce:
1. Install sale_management
2. Head to Sales > Quotations
3. Click on any quotation line
4. Click on "Add a note"
5. Input multi-line text
6. Click on the "Save manually" button
7. Click again on the note
8. Note is omly one character tall

opw-3457234

closes odoo/odoo#134231

X-original-commit: 061430f1430723d719230796774cf4efab8aa348
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
Signed-off-by: Antoine Demany (ande) <ande@odoo.com>
This commit is contained in:
Antoine (ande)
2023-09-05 16:34:41 +00:00
parent 631d34e8eb
commit 12c6eb017c
2 changed files with 44 additions and 4 deletions
@@ -48,9 +48,7 @@ export class TextField extends Component {
});
useSpellCheck({ refName: "textarea" });
if (!this.props.readonly) {
useAutoresize(this.textareaRef, { minimumHeight: this.minimumHeight });
}
useAutoresize(this.textareaRef, { minimumHeight: this.minimumHeight });
}
get isTranslatable() {
@@ -22,7 +22,6 @@ let target;
QUnit.module("Fields", (hooks) => {
hooks.beforeEach(() => {
target = getFixture();
serverData = {
models: {
partner: {
@@ -58,6 +57,17 @@ QUnit.module("Fields", (hooks) => {
},
],
},
partner_list: {
fields: {
partner_ids: {
string: "Partners",
type: "one2many",
relation: "partner",
relation_field: "id",
},
},
records: [{ id: 1, partner_ids: [1] }],
},
},
};
@@ -633,4 +643,36 @@ QUnit.module("Fields", (hooks) => {
await nextTick();
assert.containsOnce(document.body, ".o_popover .o_model_field_selector_popover");
});
QUnit.test("text field should vertical autoresize when saving", async function (assert) {
serverData.models.partner.fields.foo.type = "text";
serverData.models.partner.records[0].foo = "1";
await makeView({
type: "form",
resModel: "partner_list",
resId: 1,
serverData,
arch: `
<form>
<field name="partner_ids" widget="one2many">
<tree editable="bottom">
<field name="foo" widget="text"/>
</tree>
</field>
</form>`,
});
await click(target, "[name=foo] div");
let textarea = target.querySelector(".o_field_widget[name='foo'] textarea");
const initialHeight = textarea.offsetHeight;
await editInput(textarea, null, "1\n2\n3\n4\n5\n6\n7\n8");
await clickSave(target);
await click(target, "[name=foo] div");
textarea = target.querySelector(".o_field_widget[name='foo'] textarea");
const afterHeight = textarea.offsetHeight;
assert.ok(afterHeight > initialHeight, "Should be taller than one character");
});
});