From f317dd5bcb281f8b3ad3eee9ff6754222926e9a1 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Thu, 29 Sep 2022 12:40:03 +0000 Subject: [PATCH] [FIX] website: fix dropdown menu closing in edit mode Before this commit, in edit mode, it was not possible to close an open dropdown in the header anymore. This was due to BS5 (merged at [1]). Before, the 'show' class was added to the dropdown menu element (the element with the 'dropdown' class). But that changed: the 'show' class is now added on the button (the element with the 'dropdown-toggle' class). And as in edit mode the openings/closing of the dropdowns are handled manually in the header, it no longer worked correctly. [1]: https://github.com/odoo/odoo/commit/971e5a91aab96d36129a823e03f1f9f1b1293968 task-3001198 closes odoo/odoo#102145 X-original-commit: f3e1dc52356164453f72827e3dc87ad903df3d0e Signed-off-by: Quentin Smetz (qsm) --- addons/website/static/src/js/editor/wysiwyg.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/addons/website/static/src/js/editor/wysiwyg.js b/addons/website/static/src/js/editor/wysiwyg.js index 36e862d7c1a..c8ad83d76b4 100644 --- a/addons/website/static/src/js/editor/wysiwyg.js +++ b/addons/website/static/src/js/editor/wysiwyg.js @@ -17,15 +17,14 @@ var snippetsEditor = require('website.snippet.editor'); */ function toggleDropdown($toggles, show) { return Promise.all(_.map($toggles, toggle => { - var $toggle = $(toggle); - var $dropdown = $toggle.parent(); - var shown = $dropdown.hasClass('show'); + const $toggle = $(toggle); + const shown = toggle.classList.contains('show'); if (shown === show) { return; } - var toShow = !shown; + const toShow = !shown; return new Promise(resolve => { - $dropdown.one( + $toggle.parent().one( toShow ? 'shown.bs.dropdown' : 'hidden.bs.dropdown', () => resolve() );