[FIX] web: fix date picker fields do not capture the focus event when invisible
Before this fix, in form view, when a datepicker was not visible (because they were on another page or literally invisible), when the user pressed TAB and the datepicker was positionned after the current field in the form, it was capturing the focus during the activate phase of the navigation_move. This is not correct for invisible elements. After this fix, only focusable datepickers get the focus during the activation phase of the navigation_move. co-author: aab-odoo (aab@odoo.com)
This commit is contained in:
@@ -718,7 +718,7 @@ QUnit.module('basic_fields', {
|
||||
'<field name="qux" options="{\'type\': \'number\'}"/>' +
|
||||
'</form>',
|
||||
res_id: 4,
|
||||
translateParameters: {
|
||||
translateParameters: {
|
||||
thousands_sep: ",",
|
||||
grouping: [3, 0],
|
||||
},
|
||||
@@ -752,7 +752,7 @@ QUnit.module('basic_fields', {
|
||||
'<field name="qux"/>' +
|
||||
'</form>',
|
||||
res_id: 4,
|
||||
translateParameters: {
|
||||
translateParameters: {
|
||||
thousands_sep: ",",
|
||||
grouping: [3, 0],
|
||||
},
|
||||
@@ -761,7 +761,7 @@ QUnit.module('basic_fields', {
|
||||
form.$buttons.find('.o_form_button_edit').click();
|
||||
assert.strictEqual(form.$('.o_field_widget').attr('type'), 'text',
|
||||
'Float field with option type must have a text type (default type).');
|
||||
|
||||
|
||||
form.$('input').val('123456.7890').trigger('input');
|
||||
form.$buttons.find('.o_form_button_save').click();
|
||||
form.$buttons.find('.o_form_button_edit').click();
|
||||
@@ -2772,7 +2772,32 @@ QUnit.module('basic_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('datetime field in form view 2', function (assert) {
|
||||
|
||||
QUnit.test('datetime field not visible in form view should not capture the focus on keyboard navigation', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch:'<form string="Partners"><field name="txt"/>' +
|
||||
'<field name="datetime" invisible="True"/></form>',
|
||||
res_id: 1,
|
||||
viewOptions: {
|
||||
mode: 'edit',
|
||||
},
|
||||
});
|
||||
|
||||
form.$el.find('textarea[name=txt]').trigger($.Event('keydown', {
|
||||
which: $.ui.keyCode.TAB,
|
||||
keyCode: $.ui.keyCode.TAB,
|
||||
}));
|
||||
assert.strictEqual(document.activeElement, form.$buttons.find('.o_form_button_save')[0],
|
||||
"the save button should be selected, because the datepicker did not capture the focus");
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('datetime field with datetime formatted without second', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
this.data.partner.fields.datetime.default = "2017-08-02 12:00:05";
|
||||
@@ -3514,7 +3539,7 @@ QUnit.module('basic_fields', {
|
||||
'<field name="int_field" options="{\'type\': \'number\'}"/>' +
|
||||
'</form>',
|
||||
res_id: 4,
|
||||
translateParameters: {
|
||||
translateParameters: {
|
||||
thousands_sep: ",",
|
||||
grouping: [3, 0],
|
||||
},
|
||||
@@ -3525,7 +3550,7 @@ QUnit.module('basic_fields', {
|
||||
'Integer field with option type must have a type attribute.');
|
||||
assert.strictEqual(form.$('.o_field_widget').attr('type'), 'number',
|
||||
'Integer field with option type must have a type attribute equals to "number".');
|
||||
|
||||
|
||||
form.$('input').val('1234567890').trigger('input');
|
||||
form.$buttons.find('.o_form_button_save').click();
|
||||
form.$buttons.find('.o_form_button_edit').click();
|
||||
@@ -3534,7 +3559,7 @@ QUnit.module('basic_fields', {
|
||||
form.$buttons.find('.o_form_button_save').click();
|
||||
assert.strictEqual(form.$('.o_field_widget').text(), '1,234,567,890',
|
||||
'Integer value must be formatted in readonly view even if the input type is number.');
|
||||
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
@@ -3549,7 +3574,7 @@ QUnit.module('basic_fields', {
|
||||
'<field name="int_field"/>' +
|
||||
'</form>',
|
||||
res_id: 4,
|
||||
translateParameters: {
|
||||
translateParameters: {
|
||||
thousands_sep: ",",
|
||||
grouping: [3, 0],
|
||||
},
|
||||
@@ -3558,7 +3583,7 @@ QUnit.module('basic_fields', {
|
||||
form.$buttons.find('.o_form_button_edit').click();
|
||||
assert.strictEqual(form.$('.o_field_widget').attr('type'), 'text',
|
||||
'Integer field without option type must have a text type (default type).');
|
||||
|
||||
|
||||
form.$('input').val('1234567890').trigger('input');
|
||||
form.$buttons.find('.o_form_button_save').click();
|
||||
form.$buttons.find('.o_form_button_edit').click();
|
||||
|
||||
Reference in New Issue
Block a user