[FIX] mass_mailing: toggle fullscreen once
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) <awa@odoo.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user