[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>
This commit is contained in:
committed by
Aaron Bohy
co-authored by
Mohammed Shekha
parent
9c51b20cc0
commit
73a1e7f60e
@@ -773,7 +773,7 @@ var FieldDate = InputField.extend({
|
||||
*/
|
||||
activate: function () {
|
||||
if (this.isFocusable() && this.datewidget) {
|
||||
this.datewidget.focus();
|
||||
this.datewidget.$input.select();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user