From 96d2016cf6146879f783195beea9d019e91da5b7 Mon Sep 17 00:00:00 2001 From: Benoit Socias Date: Mon, 24 Jan 2022 13:09:19 +0000 Subject: [PATCH] [FIX] web, website: allow scrolling when only cookies bar remains Since [1] when web was migrated to OWL, the cookies bar was considered as a parent modal of any openend modal that got closed - thus preventing scrolling the full page. After this commit the cookies bar in the front end is not considered as a remaining modal anymore, and therefore does not prevent scrolling on the currently displayed website page. [1]: https://github.com/odoo/odoo/commit/29731b404fe624b733d784cd4321113d6b0d27b7 task-2741894 closes odoo/odoo#84128 X-original-commit: c1aab97e6b4e8b916c7d79db5f278c746fd6b119 Signed-off-by: Romain Derie (rde) --- .../web/static/src/legacy/js/core/dialog.js | 15 ++++++++++++- addons/website/__manifest__.py | 1 + .../website/static/src/js/widgets/dialog.js | 21 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 addons/website/static/src/js/widgets/dialog.js diff --git a/addons/web/static/src/legacy/js/core/dialog.js b/addons/web/static/src/legacy/js/core/dialog.js index 28116b674fa..37125a555d8 100644 --- a/addons/web/static/src/legacy/js/core/dialog.js +++ b/addons/web/static/src/legacy/js/core/dialog.js @@ -276,7 +276,7 @@ var Dialog = Widget.extend({ this.$modal.remove(); } - var modals = $('.modal[role="dialog"]').filter(':visible'); + const modals = $('.modal[role="dialog"]').filter(':visible').filter(this._isBlocking); if (modals.length) { if (!isFocusSet) { modals.last().focus(); @@ -341,6 +341,19 @@ var Dialog = Widget.extend({ } }); }, + /** + * Returns false for non-"blocking" dialogs. + * This is intended to be overridden by subclasses. + * + * @private + * @param {int} index + * @param {element} el The element of a dialog. + * @returns {boolean} + */ + _isBlocking(index, el) { + return true; + }, + //-------------------------------------------------------------------------- // Handlers //-------------------------------------------------------------------------- diff --git a/addons/website/__manifest__.py b/addons/website/__manifest__.py index 0929e88a907..251b9b97b1f 100644 --- a/addons/website/__manifest__.py +++ b/addons/website/__manifest__.py @@ -124,6 +124,7 @@ 'website/static/src/scss/website.ui.scss', 'website/static/src/js/utils.js', 'website/static/src/js/content/website_root.js', + 'website/static/src/js/widgets/dialog.js', 'website/static/src/js/widgets/fullscreen_indication.js', 'website/static/src/js/content/compatibility.js', 'website/static/src/js/content/menu.js', diff --git a/addons/website/static/src/js/widgets/dialog.js b/addons/website/static/src/js/widgets/dialog.js new file mode 100644 index 00000000000..df7eb514ed8 --- /dev/null +++ b/addons/website/static/src/js/widgets/dialog.js @@ -0,0 +1,21 @@ +/** @odoo-module **/ + +import Dialog from 'web.Dialog'; + +Dialog.include({ + + //-------------------------------------------------------------------------- + // Private + //-------------------------------------------------------------------------- + + /** + * @override + */ + _isBlocking(index, el) { + if (el.parentElement && el.parentElement.id === 'website_cookies_bar' + && !el.classList.contains('o_cookies_popup')) { + return false; + } + return this._super(...arguments); + }, +});