From 4999a5210d3ddca37349cf3728cd13c2f4ccf489 Mon Sep 17 00:00:00 2001 From: Benjamin Vray Date: Wed, 22 Mar 2023 13:41:55 +0000 Subject: [PATCH] [FIX] website: fix the livechat button that hides the cookies bar This commit addresses the issue where the livechat button was hiding the buttons of the cookies bar. With this commit, when a cookies bar is open, the bottom fixed elements (such as the livechat button) will be hidden. Most issues caused by bottom fixed elements hiding buttons on a page had already been addressed in this [commit]. However, the case of a modal without a backdrop (like the cookies bar) had not yet been addressed. Steps to reproduce the bug: - Activate the livechat on a website. - Activate the cookies bar on the website. - When both are open, the livechat button hides the buttons of the cookies bar (only if the page has a scrollbar and the page is not scrolled to the bottom). [commit]: https://github.com/odoo/odoo/commit/1cdd1f2f9a7d90fbf8e0da61116abfcbe6db5ae1 opw-3213808 closes odoo/odoo#117506 X-original-commit: 2e4b9cd6dbcea5844afd4b16a98d9f16abee1556 Signed-off-by: Quentin Smetz (qsm) --- .../static/src/js/content/snippets.animation.js | 14 ++++++++++++++ addons/website/static/src/snippets/s_popup/000.js | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/addons/website/static/src/js/content/snippets.animation.js b/addons/website/static/src/js/content/snippets.animation.js index 16bd00593b0..c4f645365d4 100644 --- a/addons/website/static/src/js/content/snippets.animation.js +++ b/addons/website/static/src/js/content/snippets.animation.js @@ -1194,6 +1194,20 @@ registry.BottomFixedElement = publicWidget.Widget.extend({ return; } + // The bottom fixed elements are always hidden when a modal is open + // thanks to the CSS that is based on the 'modal-open' class added to + // the body. However, when the modal does not have a backdrop (e.g. + // cookies bar), this 'modal-open' class is not added. That's why we + // handle it here. Note that the popup widget code triggers a 'scroll' + // event when the modal is hidden to make the bottom fixed elements + // reappear. + if (this.el.querySelector('.s_popup_no_backdrop.show')) { + for (const el of $bottomFixedElements) { + el.classList.add('o_bottom_fixed_element_hidden'); + } + return; + } + this._restoreBottomFixedElements($bottomFixedElements); if ((this.$scrollingElement[0].offsetHeight + this.$scrollingElement[0].scrollTop) >= (this.$scrollingElement[0].scrollHeight - 2)) { const buttonEls = [...this.$('a:visible, .btn:visible')]; diff --git a/addons/website/static/src/snippets/s_popup/000.js b/addons/website/static/src/snippets/s_popup/000.js index 196276066e2..7c2ebca1c42 100644 --- a/addons/website/static/src/snippets/s_popup/000.js +++ b/addons/website/static/src/snippets/s_popup/000.js @@ -52,6 +52,14 @@ const SharedPopupWidget = publicWidget.Widget.extend({ * @private */ _onModalHidden() { + if (this.el.querySelector('.s_popup_no_backdrop')) { + // We trigger a scroll event here to call the + // '_hideBottomFixedElements' method and re-display any bottom fixed + // elements that may have been hidden (e.g. the live chat button + // hidden when the cookies bar is open). + $().getScrollingElement()[0].dispatchEvent(new Event('scroll')); + } + this.el.classList.add('d-none'); }, });