[FIX] web: unselect row before resequencing in editable list
If a row is being edited, this row will be refocused when performing changes (i.e. resequencing records). It can cause an issue if an onchange modifies the record being focused. To avoid this issue, the row is unselected before resequencing records. The row isn't selected anymore but this behaviour wasn't expected anyway.
This commit is contained in:
committed by
Martin Geubelle
parent
1c7e0df5a5
commit
091c86c21b
@@ -579,11 +579,12 @@ ListRenderer.include({
|
||||
if (!asc) {
|
||||
rowIDs.reverse();
|
||||
}
|
||||
|
||||
this.trigger_up('resequence', {
|
||||
rowIDs: rowIDs,
|
||||
offset: _.min(sequences),
|
||||
handleField: this.handleField,
|
||||
this.unselectRow().then(function () {
|
||||
self.trigger_up('resequence', {
|
||||
rowIDs: rowIDs,
|
||||
offset: _.min(sequences),
|
||||
handleField: self.handleField,
|
||||
});
|
||||
});
|
||||
},
|
||||
/**
|
||||
|
||||
@@ -2410,6 +2410,57 @@ QUnit.module('relational_fields', {
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('onchange (with command 5) for embedded one2many with handle widget', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
this.data.partner.records[0].turtles = [1, 2, 3];
|
||||
this.data.partner.onchanges = {
|
||||
turtles: function (obj) {
|
||||
obj.turtles = [[5]].concat(obj.turtles);
|
||||
},
|
||||
};
|
||||
|
||||
var form = createView({
|
||||
View: FormView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch:'<form string="Partners">' +
|
||||
'<sheet>' +
|
||||
'<group>' +
|
||||
'<field name="turtles">' +
|
||||
'<tree editable="bottom" default_order="turtle_int">' +
|
||||
'<field name="turtle_int" widget="handle"/>' +
|
||||
'<field name="turtle_foo"/>' +
|
||||
'</tree>' +
|
||||
'</field>' +
|
||||
'</group>' +
|
||||
'</sheet>' +
|
||||
'</form>',
|
||||
res_id: 1,
|
||||
});
|
||||
|
||||
assert.strictEqual(form.$('td.o_data_cell:not(.o_handle_cell)').text(), "yopblipkawa",
|
||||
"should have the 3 rows in the correct order");
|
||||
|
||||
form.$buttons.find('.o_form_button_edit').click();
|
||||
form.$('.o_field_one2many .o_list_view tbody tr:first td:first').click();
|
||||
form.$('.o_field_one2many .o_list_view tbody tr:first input:first').val('blurp').trigger('input');
|
||||
|
||||
// Drag and drop the third line in second position
|
||||
testUtils.dragAndDrop(
|
||||
form.$('.ui-sortable-handle').eq(2),
|
||||
form.$('.o_field_one2many tbody tr').eq(1),
|
||||
{position: 'top'}
|
||||
);
|
||||
|
||||
form.$buttons.find('.o_form_button_save').click();
|
||||
|
||||
assert.strictEqual(form.$('.o_data_cell:not(.o_handle_cell)').text(), "blurpkawablip",
|
||||
"should display to record in 'turtle_int' order");
|
||||
|
||||
form.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('embedded one2many with handle widget with minimum setValue calls', function (assert) {
|
||||
var done = assert.async();
|
||||
assert.expect(20);
|
||||
|
||||
Reference in New Issue
Block a user