[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) <qsm@odoo.com>
This commit is contained in:
Benjamin Vray
2023-04-03 18:08:53 +02:00
committed by qsm-odoo
parent b44754dcaf
commit 4999a5210d
2 changed files with 22 additions and 0 deletions
@@ -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')];
@@ -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');
},
});