From 6c07b1cff9cbf044f9aa698f6d0fbf7985648b1d Mon Sep 17 00:00:00 2001 From: Daniel Lockyer Date: Wed, 26 Jun 2024 10:57:36 +0200 Subject: [PATCH] Fixed TypeError when editor is focussed when not loaded fix https://linear.app/tryghost/issue/SLO-162/typeerror-thiseditorapi-is-null - if the editor does not load for some reason (network issue), and the editor area is clicked, we throw an error because we don't protect against a null `editorAPI` - this adds that check --- ghost/admin/app/components/gh-koenig-editor-lexical.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghost/admin/app/components/gh-koenig-editor-lexical.js b/ghost/admin/app/components/gh-koenig-editor-lexical.js index 8dcf8d6d35..2319ae9c8a 100644 --- a/ghost/admin/app/components/gh-koenig-editor-lexical.js +++ b/ghost/admin/app/components/gh-koenig-editor-lexical.js @@ -236,7 +236,7 @@ export default class GhKoenigEditorLexical extends Component { // otherwise the browser will defocus the editor and the cursor will disappear @action focusEditor(event) { - if (!this.skipFocusEditor && event.target.classList.contains('gh-koenig-editor-pane')) { + if (!this.skipFocusEditor && event.target.classList.contains('gh-koenig-editor-pane') && this.editorAPI) { let editorCanvas = this.editorAPI.editorInstance.getRootElement(); let {bottom} = editorCanvas.getBoundingClientRect();