Skip to content

Commit 3ac0416

Browse files
[FIX] mass_mailing_egg: FIXUP force fullscreen for mobile editor
1 parent 7e742e3 commit 3ac0416

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

addons/mass_mailing/static/src/iframe/mass_mailing_iframe.js

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
onWillDestroy,
66
onWillUpdateProps,
77
status,
8+
toRaw,
89
useEffect,
910
useRef,
1011
useState,
@@ -20,6 +21,7 @@ import { Editor } from "@html_editor/editor";
2021
import { useThrottleForAnimation } from "@web/core/utils/timing";
2122
import { closestScrollableY } from "@web/core/utils/scrolling";
2223
import { _t } from "@web/core/l10n/translation";
24+
import { effect } from "@web/core/utils/reactive";
2325

2426
const IFRAME_VALUE_SELECTOR = ".o_mass_mailing_value";
2527

@@ -61,9 +63,12 @@ export class MassMailingIframe extends Component {
6163
useSubEnv({
6264
localOverlayContainerKey: uniqueId("mass_mailing_iframe"),
6365
});
66+
let showFullscreen = false;
67+
let isMobile = false;
6468
this.state = useState({
65-
isMobile: false,
69+
isMobile,
6670
ready: false,
71+
showFullscreen,
6772
});
6873
this.iframeLoaded = new Deferred();
6974
onMounted(() => {
@@ -94,9 +99,31 @@ export class MassMailingIframe extends Component {
9499
},
95100
() => [this.state.showFullscreen]
96101
);
97-
if (!this.props.readonly && this.props.withBuilder) {
98-
this.state.showFullscreen = false;
99-
} else if (!this.props.readonly) {
102+
effect(
103+
(state) => {
104+
if (status(this) === "destroyed") {
105+
return;
106+
}
107+
if (showFullscreen && !state.showFullscreen && toRaw(state).isMobile) {
108+
state.isMobile = false;
109+
}
110+
showFullscreen = state.showFullscreen;
111+
},
112+
[this.state]
113+
);
114+
effect(
115+
(state) => {
116+
if (status(this) === "destroyed") {
117+
return;
118+
}
119+
if (!isMobile && state.isMobile && !toRaw(state).showFullscreen) {
120+
state.showFullscreen = true;
121+
}
122+
isMobile = state.isMobile;
123+
},
124+
[this.state]
125+
);
126+
if (!this.props.readonly && !this.props.withBuilder) {
100127
this.editor = new Editor(this.props.config, this.env.services);
101128
this.props.onEditorLoad(this.editor);
102129
onWillDestroy(() => {

0 commit comments

Comments
 (0)