summaryrefslogtreecommitdiff
path: root/addons/web/static/tests/views/form_tests.js
diff options
context:
space:
mode:
authorHardik Prajapati <hap@odoo.com>2020-04-30 13:22:01 +0000
committerAaron Bohy <aab@odoo.com>2020-05-12 06:30:21 +0000
commit73a1e7f60ef48ee697ee9cb7d79405a4e56b3e2f (patch)
tree0d6e39d9f3d13978c9373d2f085f347be9bad0db /addons/web/static/tests/views/form_tests.js
parent9c51b20cc0ddcb857c17f64f210288e328135bdf (diff)
[FIX] web: select date/datetime value when tabbing in
before this commit, tabbing into the date or datetime field input it has only focus, value is not selected. after this commit, navigate through a view in edit mode with the TAB key, when focus comes into date/dateetime field input then input is focused and value of date/datetime field is also get selected. task-2246593 closes odoo/odoo#51062 X-original-commit: 962e4e18b559d90aa3456c77035659ac8017501d Signed-off-by: Aaron Bohy (aab) <aab@odoo.com> Co-authored-by: Mohammed Shekha <msh@odoo.com>
Diffstat (limited to 'addons/web/static/tests/views/form_tests.js')
-rw-r--r--addons/web/static/tests/views/form_tests.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/addons/web/static/tests/views/form_tests.js b/addons/web/static/tests/views/form_tests.js
index 77df0909de4..3427244881b 100644
--- a/addons/web/static/tests/views/form_tests.js
+++ b/addons/web/static/tests/views/form_tests.js
@@ -4472,6 +4472,52 @@ QUnit.module('Views', {
form.destroy();
});
+ QUnit.test('navigation with tab key selects a value in form view', async function (assert) {
+ assert.expect(5);
+
+ const form = await createView({
+ View: FormView,
+ model: 'partner',
+ data: this.data,
+ arch: `
+ <form>
+ <field name="display_name"/>
+ <field name="int_field"/>
+ <field name="qux"/>
+ <field name="trululu"/>
+ <field name="date"/>
+ <field name="datetime"/>
+ </form>`,
+ res_id: 1,
+ viewOptions: {
+ mode: 'edit',
+ },
+ });
+
+ await testUtils.dom.click(form.el.querySelector('input[name="display_name"]'));
+ await testUtils.fields.triggerKeydown(document.activeElement, 'tab');
+ assert.strictEqual(document.getSelection().toString(), "10",
+ "int_field value should be selected");
+
+ await testUtils.fields.triggerKeydown(document.activeElement, 'tab');
+ assert.strictEqual(document.getSelection().toString(), "0.4",
+ "qux field value should be selected");
+
+ await testUtils.fields.triggerKeydown(document.activeElement, 'tab');
+ assert.strictEqual(document.getSelection().toString(), "aaa",
+ "trululu field value should be selected");
+
+ await testUtils.fields.triggerKeydown(document.activeElement, 'tab');
+ assert.strictEqual(document.getSelection().toString(), "01/25/2017",
+ "date field value should be selected");
+
+ await testUtils.fields.triggerKeydown(document.activeElement, 'tab');
+ assert.strictEqual(document.getSelection().toString(), "12/12/2016 10:55:05",
+ "datetime field value should be selected");
+
+ form.destroy();
+ });
+
QUnit.test('clicking on a stat button with a context', async function (assert) {
assert.expect(1);