[FIX] website: prevent page overflow with mobile menu open

Since [commit 1] replaced the mobile menu, a bug appeared on Safari
where the `#wrapwrap` element would still be scrollable even with the
menu open and even though the `body` has `overflow: hidden;`.
This commit fixes it.

[commit 1]: https://github.com/odoo/odoo/commit/bc13176de8d66bbdc1c536017b1f046c5fd31a86

task-3584299

closes odoo/odoo#141154

Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
Robin Lejeune (role)
2023-11-15 16:54:45 +00:00
parent fbcab1fccc
commit f6d9f80e6e
@@ -661,6 +661,8 @@ publicWidget.registry.HeaderGeneral = publicWidget.Widget.extend({
'hidden.bs.collapse #top_menu_collapse': '_onCollapseHidden',
"show.bs.modal #o_search_modal": "_onSearchModalShow",
"shown.bs.modal #o_search_modal": "_onSearchModalShown",
"shown.bs.offcanvas #top_menu_collapse_mobile": "_onMobileMenuToggled",
"hidden.bs.offcanvas #top_menu_collapse_mobile": "_onMobileMenuToggled",
},
//--------------------------------------------------------------------------
@@ -679,6 +681,14 @@ publicWidget.registry.HeaderGeneral = publicWidget.Widget.extend({
_onCollapseHidden() {
this.el.classList.remove('o_top_menu_collapse_shown');
},
/**
* @private
*/
_onMobileMenuToggled(ev) {
// TODO: Fix for Safari. Once the scroll is moved back from the
// #wrapwrap to the body, this code should not be needed anymore.
document.querySelector("#wrapwrap").classList.toggle("overflow-hidden");
},
/**
* @private
*/