Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] web: list editable create then escape #31342

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons/web/static/src/js/views/list/list_editable_renderer.js
Expand Up @@ -278,15 +278,15 @@ ListRenderer.include({
this.currentRow = null;
}

// destroy widgets first
this._destroyFieldWidgets(recordID);
// remove the row
var $row = this.$('.o_data_row:nth(' + rowIndex + ')');
if (this.state.count >= 4) {
$row.remove();
} else {
$row.replaceWith(this._renderEmptyRow());
}

this._destroyFieldWidgets(recordID);
},
/**
* Updates the already rendered row associated to the given recordID so that
Expand Down
46 changes: 46 additions & 0 deletions addons/web/static/tests/views/list_tests.js
Expand Up @@ -10,6 +10,7 @@ var ListView = require('web.ListView');
var mixins = require('web.mixins');
var NotificationService = require('web.NotificationService');
var testUtils = require('web.test_utils');
var testUtilsDom = require('web.test_utils_dom');
var widgetRegistry = require('web.widget_registry');
var Widget = require('web.Widget');

Expand Down Expand Up @@ -277,6 +278,51 @@ QUnit.module('Views', {
list.destroy();
});

QUnit.test('editable list datetimepicker destroy widget', function (assert) {
assert.expect(7);
var done = assert.async();

var list = createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree editable="top">' +
'<field name="date"/>' +
'</tree>',
});
list.$el.on({
'show.datetimepicker': function () {
assert.equal($('.bootstrap-datetimepicker-widget').length, 1,
'The datetimepicker is open');

assert.equal(list.$('.o_data_row').length, 5,
'There should be 5 rows');

assert.equal(list.$('.o_selected_row').length, 1,
'One row in edit mode');

list.$('input.o_datepicker_input').trigger($.Event('keydown', {which: $.ui.keyCode.ESCAPE}));

assert.equal(list.$('.o_data_row').length, 4,
'There should be 4 rows');

assert.equal(list.$('.o_selected_row').length, 0,
'No row should be in edit mode');

done();
}
});
assert.equal(list.$('.o_data_row').length, 4,
'There should be 4 rows');

assert.equal(list.$('.o_selected_row').length, 0,
'No row should be in edit mode');

testUtilsDom.click(list.$buttons.find('.o_list_button_add'));

list.destroy();
});

QUnit.test('at least 4 rows are rendered, even if less data', function (assert) {
assert.expect(1);

Expand Down