From 37d9e8bb8b22055be7bd1b13a0031f9572e58840 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 24 Nov 2022 10:53:55 +0000 Subject: [PATCH] Fixed `Cannot set properties of null (setting 'scrollTop')` errors in `` closes sentry ADMIN-C7S - we can't guarantee that the iframe being swapped to has rendered yet at the time we swap iframes so we need a guard around the `contentDocument.body` property existing before setting it's `scrollTop` value --- ghost/admin/app/components/gh-html-iframe.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ghost/admin/app/components/gh-html-iframe.js b/ghost/admin/app/components/gh-html-iframe.js index 0b84c24c3f..dce995497b 100644 --- a/ghost/admin/app/components/gh-html-iframe.js +++ b/ghost/admin/app/components/gh-html-iframe.js @@ -69,7 +69,9 @@ export default class GhHtmlIframeComponent extends Component { } this._lastPageId = this.args.pageId; - this.iframes[this.toRenderIframe].contentDocument.body.scrollTop = newScrollTop; + if (this.iframes[this.toRenderIframe].contentDocument.body) { + this.iframes[this.toRenderIframe].contentDocument.body.scrollTop = newScrollTop; + } this.iframes[this.toRenderIframe].style = this.visibleIframeStyle; this.renderedIframe = this.toRenderIframe; this.toRenderIframe = this.toRenderIframe === 0 ? 1 : 0;