[FIX] web: tab navigation with phone widgets in form view

This commit ensures that tab navigation works properly when editing a
form view that contains input fields with phone widgets. Previously,
pressing TAB would skip those fields.
This commit is contained in:
Khoi Nguyen
2017-10-16 11:34:39 +02:00
committed by Khoi Nguyen
parent 4f0d6f5ae1
commit bb692c76d4
2 changed files with 28 additions and 1 deletions
@@ -966,7 +966,7 @@ var FieldPhone = FieldEmail.extend({
* @override
*/
getFocusableElement: function () {
if (this._canCall()) {
if (this.mode !== 'readonly' || this._canCall()) {
return this._super.apply(this, arguments);
}
return $();
@@ -2828,6 +2828,33 @@ QUnit.module('basic_fields', {
form.destroy();
});
QUnit.test('use TAB to navigate to a phone field', function (assert) {
assert.expect(2);
var form = createView({
View: FormView,
model: 'partner',
data: this.data,
arch:'<form string="Partners">' +
'<sheet>' +
'<group>' +
'<field name="display_name"/>' +
'<field name="foo" widget="phone"/>' +
'</group>' +
'</sheet>' +
'</form>',
});
form.$('input[name=display_name]').click();
assert.strictEqual(form.$('input[name="display_name"]')[0], document.activeElement,
"display_name should be focused");
form.$('input[name="display_name"]').trigger($.Event('keydown', {which: $.ui.keyCode.TAB}));
assert.strictEqual(form.$('input[name="foo"]')[0], document.activeElement,
"foo should be focused");
form.destroy();
});
QUnit.module('PriorityWidget');
QUnit.test('priority widget when not set', function (assert) {