From e7635bc705ec37cbec7edb809734e39381822c51 Mon Sep 17 00:00:00 2001 From: Renaud Thiry Date: Tue, 1 Aug 2023 07:51:43 +0000 Subject: [PATCH] [FIX] mass_mailing: toggle fullscreen once MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 16.0 and up, when toggling full-screen mode on the mailing editor the iframe content is not properly made scrollable. This is due to the toggle method being triggered 4 times which effectively cancels the effect. The reason for it being triggered 4 times is that the check that would prevent multiple event listeners from being set on the button compares an existing jquery object to a new one on the same element. As these are two different references to the same element they are still different objects and thus the listener will be added even if they reference the same iframe. The fix is simply to compare the html elements directly, if they exist. We also add the expected state of 'full screen' to the class toggle as it may avoid other inconsistencies from blindly toggling. task-3446768 closes odoo/odoo#130853 X-original-commit: 30f27563868af4b247c96c24135c1003aa191cef Signed-off-by: Warnon Aurélien (awa) --- .../static/src/js/mailing_mailing_view_form_full_width.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js b/addons/mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js index 31e9c296df9..2b7be0e2a6e 100644 --- a/addons/mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js +++ b/addons/mass_mailing/static/src/js/mailing_mailing_view_form_full_width.js @@ -51,7 +51,7 @@ export class MassMailingFullWidthViewController extends formView.Controller { if (!$iframe.length || !$iframe.contents().length) { return; } - const hasIframeChanged = $iframe !== this.$iframe; + const hasIframeChanged = !this.$iframe || !this.$iframe.length || $iframe[0] !== this.$iframe[0]; this.$iframe = $iframe; this._resizeMailingEditorIframe(); @@ -110,11 +110,11 @@ export class MassMailingFullWidthViewController extends formView.Controller { * @private */ _onToggleFullscreen() { + const isFullscreen = this._isFullScreen(); const $iframeDoc = this.$iframe.contents(); const html = $iframeDoc.find('html').get(0); html.scrollTop = 0; - html.classList.toggle('o_fullscreen'); - const isFullscreen = this._isFullScreen(); + html.classList.toggle('o_fullscreen', isFullscreen); const wysiwyg = $iframeDoc.find('.note-editable').data('wysiwyg'); if (wysiwyg && wysiwyg.snippetsMenu) { // Restore the appropriate scrollable depending on the mode.