From 157732cfb15d743c66c36a1bdcb350026a0473e4 Mon Sep 17 00:00:00 2001 From: Martin Geubelle Date: Tue, 27 Jun 2017 17:56:00 +0200 Subject: [FIX] web: FieldText: keep editing the textarea after enter In the editable list, when pressing enter, the cursor goes to the next line and the current row is saved. This should not be the case for a textarea (i.e. in the FieldText widget). In this particular case, we just want to continue editing the textarea. --- .../web/static/tests/fields/basic_fields_tests.js | 34 ++++++++++++++++++++++ 1 file changed, 34 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 8f26c922a83..50daedb7dcb 100644 --- a/addons/web/static/tests/fields/basic_fields_tests.js +++ b/addons/web/static/tests/fields/basic_fields_tests.js @@ -1043,6 +1043,40 @@ QUnit.module('basic_fields', { _t.database.multi_lang = multiLang; }); + QUnit.test('go to next line (and not the next row) when pressing enter', function (assert) { + assert.expect(4); + + this.data.partner.fields.foo.type = 'text'; + var list = createView({ + View: ListView, + model: 'partner', + data: this.data, + arch: '' + + '' + + '' + + '' + + '', + }); + + list.$('tbody tr:first .o_list_text').click(); + var $textarea = list.$('textarea.o_field_text'); + assert.strictEqual($textarea.length, 1, "should have a text area"); + assert.strictEqual($textarea.val(), 'yop', 'should still be "yop" in edit'); + + assert.strictEqual(list.$('textarea').get(0), document.activeElement, + "text area should have the focus"); + + // click on enter + list.$('textarea') + .trigger({type: "keydown", which: $.ui.keyCode.ENTER}) + .trigger({type: "keyup", which: $.ui.keyCode.ENTER}); + + assert.strictEqual(list.$('textarea').first().get(0), document.activeElement, + "text area should still have the focus"); + + list.destroy(); + }); + QUnit.module('FieldBinary'); QUnit.test('binary fields are correctly rendered', function (assert) { -- cgit v1.2.3