diff --git a/addons/web/static/src/legacy/js/views/list/list_controller.js b/addons/web/static/src/legacy/js/views/list/list_controller.js index 0679f86d25f9cb0670870d77d59b4ca175eb24ba..703c6c121ca36349d5007864ae9211241e07a3c7 100644 --- a/addons/web/static/src/legacy/js/views/list/list_controller.js +++ b/addons/web/static/src/legacy/js/views/list/list_controller.js @@ -659,6 +659,7 @@ var ListController = BasicController.extend({ * @private */ _updateSelectionBox() { + this._renderHeaderButtons(); if (this.$selectionBox) { this.$selectionBox.remove(); this.$selectionBox = null; @@ -674,7 +675,6 @@ var ListController = BasicController.extend({ })); this.$selectionBox.appendTo(this.$buttons); } - this._renderHeaderButtons(); }, //-------------------------------------------------------------------------- diff --git a/addons/web/static/tests/legacy/views/list_tests.js b/addons/web/static/tests/legacy/views/list_tests.js index ab1356f30a191e4dea8bf7c332bd1cd9d6c69176..069bc17f4480c0578b8b3427d34514f0061c3969 100644 --- a/addons/web/static/tests/legacy/views/list_tests.js +++ b/addons/web/static/tests/legacy/views/list_tests.js @@ -557,7 +557,7 @@ QUnit.module('Views', { assert.hasClass(cpButtons[0].querySelector('button[name="x"]'), 'btn btn-secondary'); assert.containsOnce(cpButtons[0], '.o_list_selection_box'); assert.strictEqual( - cpButtons[0].querySelector('button[name="x"]').previousElementSibling, + cpButtons[0].querySelector('button[name="x"]').nextElementSibling, cpButtons[0].querySelector('.o_list_selection_box') ); assert.containsNone(cpButtons[0], 'button[name="y"]'); @@ -2234,6 +2234,38 @@ QUnit.module('Views', { list.destroy(); }); + QUnit.test('selection box is displayed after header buttons', async function (assert) { + assert.expect(5); + + const list = await createView({ + View: ListView, + model: 'foo', + data: this.data, + arch: + `<tree> + <header> + <button name="x" type="object" class="plaf" string="plaf"/> + <button name="y" type="object" class="plouf" string="plouf"/> + </header> + <field name="foo"/> + <field name="bar"/> + </tree>`, + }); + + assert.containsN(list, '.o_data_row', 4); + assert.containsNone(list.$('.o_cp_buttons'), '.o_list_selection_box'); + + // select a record + await testUtils.dom.click(list.$('.o_data_row:first .o_list_record_selector input')); + assert.containsOnce(list.$('.o_cp_buttons'), '.o_list_selection_box'); + const lastElement = list.$('.o_cp_buttons .o_list_buttons').children(":last")[0]; + assert.strictEqual(lastElement, list.$('.o_cp_buttons .o_list_selection_box')[0], + "last element should selection box"); + assert.strictEqual(list.$('.o_list_selection_box').text().trim(), '1 selected'); + + list.destroy(); + }); + QUnit.test('selection box is removed after multi record edition', async function (assert) { assert.expect(6);