Fixed Cannot set properties of null (setting 'scrollTop') errors in <GhHtmlIframe>

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
This commit is contained in:
Kevin Ansfield 2022-11-24 10:53:55 +00:00
parent c5abef057c
commit 37d9e8bb8b

View File

@ -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;