From 65e1ffb34d7a8b888e2b98b29c351dabf408988a Mon Sep 17 00:00:00 2001 From: luvi Date: Thu, 23 Nov 2023 10:50:40 +0100 Subject: [PATCH] [FIX] web_editor: fix reset when triggering scroll This commit fixes the behavior hiding the select element when scrolling has happened. Instead of the 'scroll' event, 'mousewheel' was used, which isn't triggered when scrolling on a touch device. Now, the correct event is used, and the listener is given to the actual document element, instead of being globally listening on window (in case of iframes). This fix is part of a bug happening in the report editor of Studio, since the select element wouldn't be reset when scrolling, but kept visible at the same outdated position. ticket-3496665 closes odoo/odoo#144178 X-original-commit: f53f8b2f2cba5e586dd376ddd7ec39a16741f66a Signed-off-by: Aaron Bohy (aab) --- addons/web_editor/static/src/js/backend/QWebPlugin.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/addons/web_editor/static/src/js/backend/QWebPlugin.js b/addons/web_editor/static/src/js/backend/QWebPlugin.js index 9258f86a181..fb42d66da78 100644 --- a/addons/web_editor/static/src/js/backend/QWebPlugin.js +++ b/addons/web_editor/static/src/js/backend/QWebPlugin.js @@ -194,8 +194,6 @@ export class QWebPlugin { ); } _updateBranchingSelectionPosition(target) { - window.addEventListener('mousewheel', this._hideBranchingSelection); - const box = target.getBoundingClientRect(); const selBox = this._selectElWrapper.getBoundingClientRect(); const parentBox = this._getContextFromParentRect(); @@ -207,6 +205,7 @@ export class QWebPlugin { this._selectElWrapper.style.top = `${top}px`; } _renderBranchingSelection(target) { + this._document.addEventListener('scroll', this._hideBranchingSelection); const selectEl = document.createElement('select'); const groupId = parseInt(target.getAttribute('data-oe-t-group')); const groupElements = target.parentElement.querySelectorAll( @@ -244,6 +243,6 @@ export class QWebPlugin { _hideBranchingSelection() { this._selectElWrapper.style.display = 'none'; this._selectElWrapper.innerHTML = ``; - window.removeEventListener('mousewheel', this._hideBranchingSelection); + this._document.removeEventListener('scroll', this._hideBranchingSelection); } }