Fixed Signup Embed iFrame not loading in Safari (#16935)

refs https://github.com/TryGhost/Team/issues/3375

- Fixed a safari bug that caused the signup embed iframe to be in the
`onLoad` state perpetually, causing it not to render.
This commit is contained in:
Ronald Langeveld 2023-06-05 12:01:55 +02:00 committed by GitHub
parent ffe5cd765a
commit 52150d5ffb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,6 +5,7 @@ import {tracked} from '@glimmer/tracking';
export default class Preview extends Component {
iframe;
iframeRoot;
isContentLoaded = false;
/**
* When updating the frame, to avoid layout jumps, we'll reuse the last known height
@ -15,7 +16,9 @@ export default class Preview extends Component {
@action
onLoad(event) {
this.iframe = event.currentTarget;
this.updateContent();
if (!this.isContentLoaded) {
this.updateContent();
}
this.onResize();
(new ResizeObserver(() => this.onResize(this.iframeRoot)))?.observe?.(this.iframeRoot);
}
@ -33,6 +36,10 @@ export default class Preview extends Component {
this.iframe.contentWindow.document.close();
this.iframeRoot = this.iframe.contentDocument.body;
// fix for Safari causing the iframe load to inifite loop
// Set the flag indicating the content has been loaded
this.isContentLoaded = true;
}
@action