summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/fields/relational_fields_tests.js
diff options
context:
space:
mode:
authorVincent Schippefilt <vsc@odoo.com>2018-09-03 16:20:06 +0200
committerVincent Schippefilt <vsc@odoo.com>2018-09-25 16:49:22 +0200
commite343f5f5f95607b91a61fed167a6f11f0eeaeaa8 (patch)
treed9cc4b8ff39fedc17db36c7f1ed3fbc1fea2ec5f /addons/web/static/tests/fields/relational_fields_tests.js
parent3dcf20284df9fb411a7093537ccd645a34543b20 (diff)
[IMP] web: x2many adds a new line by tabbing on a not dirty line
Before this change, when the focus was on the first field on a x2many field, and the user pressed TAB, the line would be discarded and the focus moved to the next field (at the level of the x2many) in the form. This was an issue because if the first field was required, the focus could not be moved out of the field with TAB so the user had to discard the line manually (with ESC) before moving to the next field This change works with 2 changes: 1. detecting if a line is dirty (has been modified by the user) and at the end of the line, decide to either - discard the line and move the next field, if the line is not dirty - commit the line and add a new line, if the line is dirty 2. allow users to use TAB through required field inside x2many so they can easilly go to the end of the line. Task id : 1872248
Diffstat (limited to 'addons/web/static/tests/fields/relational_fields_tests.js')
-rw-r--r--addons/web/static/tests/fields/relational_fields_tests.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/addons/web/static/tests/fields/relational_fields_tests.js b/addons/web/static/tests/fields/relational_fields_tests.js
index 8809d219e49..63ac20a0a32 100644
--- a/addons/web/static/tests/fields/relational_fields_tests.js
+++ b/addons/web/static/tests/fields/relational_fields_tests.js
@@ -13493,7 +13493,8 @@ QUnit.module('relational_fields', {
form.destroy();
});
- QUnit.test('when Navigating to a many to one with tabs, not filling in the first field and hitting tab, we should not add a first line but navigate to the next control', function (assert) {
+ QUnit.test('when Navigating to a many2one with tabs, not filling any field and hitting tab,' +
+ ' we should not add a first line but navigate to the next control', function (assert) {
assert.expect(3);
this.data.partner.records[0].turtles = [];
@@ -13536,6 +13537,10 @@ QUnit.module('relational_fields', {
keyCode: $.ui.keyCode.TAB,
}));
+ // skips the first field of the one2many
+ $(document.activeElement).trigger($.Event('keydown', {which: $.ui.keyCode.TAB}));
+
+ // skips the second (and last) field of the one2many
$(document.activeElement).trigger($.Event('keydown', {which: $.ui.keyCode.TAB}));
assert.strictEqual(assert.strictEqual(form.$el.find('input[name="foo"]')[0],