diff --git a/addons/web/static/src/js/components/dropdown_menu.js b/addons/web/static/src/js/components/dropdown_menu.js index 4b77bdc4527..ca514e4a5bf 100644 --- a/addons/web/static/src/js/components/dropdown_menu.js +++ b/addons/web/static/src/js/components/dropdown_menu.js @@ -35,7 +35,7 @@ odoo.define('web.DropdownMenu', function (require) { this.dropdownMenu = useRef('dropdown'); this.state = useState({ open: false }); - useExternalListener(window, 'click', this._onWindowClick); + useExternalListener(window, 'click', this._onWindowClick, true); useExternalListener(window, 'keydown', this._onWindowKeydown); } @@ -147,6 +147,13 @@ odoo.define('web.DropdownMenu', function (require) { !this.el.contains(ev.target) && !this.el.contains(document.activeElement) ) { + if (document.body.classList.contains("modal-open")) { + // retrieve the active modal and check if the dropdown is a child of this modal + const modal = document.querySelector('.modal:not(.o_inactive_modal)'); + if (!modal.contains(this.el)) { + return; + } + } this.state.open = false; } } diff --git a/addons/web/static/tests/components/dropdown_menu_tests.js b/addons/web/static/tests/components/dropdown_menu_tests.js index da0d458d680..3aff0ae14ea 100644 --- a/addons/web/static/tests/components/dropdown_menu_tests.js +++ b/addons/web/static/tests/components/dropdown_menu_tests.js @@ -68,6 +68,62 @@ odoo.define('web.dropdown_menu_tests', function (require) { dropdown.destroy(); }); + QUnit.test('only one dropdown rendering at same time (owl vs bootstrap dropdown)', async function (assert) { + assert.expect(12); + + const bsDropdown = document.createElement('div'); + bsDropdown.innerHTML = `