From 38eac736ece7abf1adf216095d26693f9f08204e Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 6 Jan 2021 08:27:57 +0000 Subject: [PATCH] [FIX] web: editable list: can unselect row MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since commit [1], it is no longer possible to unselect a row in a one2many editable list if there is an html field in the form view. The reason is that there is a '.modal' element (several actually) in the DOM of the html field. This element is considered as an opened dialog by the list renderer, which is wrong. This commit refines the selector that determines whether there is an opened dialog or not. [1] 7d04ec7cca4f355295a06c1ce6f112b6cc533c87 closes odoo/odoo#64134 X-original-commit: 6be8997807e4fbfeeefe273a335d9182490d0ac5 Signed-off-by: Géry Debongnie (ged) Signed-off-by: Aaron Bohy (aab) --- .../js/views/list/list_editable_renderer.js | 2 +- addons/web/static/tests/views/list_tests.js | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/views/list/list_editable_renderer.js b/addons/web/static/src/js/views/list/list_editable_renderer.js index 8a6295ce23c..fde02863f33 100644 --- a/addons/web/static/src/js/views/list/list_editable_renderer.js +++ b/addons/web/static/src/js/views/list/list_editable_renderer.js @@ -1807,7 +1807,7 @@ ListRenderer.include({ // ignore clicks if there is a modal, except if the list is in the last // (active) modal - var $modal = $('.modal:last'); + var $modal = $('body > .modal:last'); if ($modal.length) { var $listModal = this.$el.closest('.modal'); if ($modal.prop('id') !== $listModal.prop('id')) { diff --git a/addons/web/static/tests/views/list_tests.js b/addons/web/static/tests/views/list_tests.js index f5c475889c3..d4c503c6cc0 100644 --- a/addons/web/static/tests/views/list_tests.js +++ b/addons/web/static/tests/views/list_tests.js @@ -8276,6 +8276,38 @@ QUnit.module('Views', { form.destroy(); }); + QUnit.test('editable list alongside html field: click out to unselect the row', async function (assert) { + assert.expect(5); + + const form = await createView({ + View: FormView, + model: 'foo', + data: this.data, + arch: ` +
+ + + + + + + `, + }); + + assert.containsNone(form, '.o_data_row'); + + await testUtils.dom.click(form.$('.o_field_x2many_list_row_add > a')); + assert.containsOnce(form, '.o_data_row'); + assert.hasClass(form.$('.o_data_row'), 'o_selected_row'); + + // click outside to unselect the row + await testUtils.dom.click(document.body); + assert.containsOnce(form, '.o_data_row'); + assert.doesNotHaveClass(form.$('.o_data_row'), 'o_selected_row'); + + form.destroy(); + }); + QUnit.test('list grouped by date:month', async function (assert) { assert.expect(1);