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
This commit is contained in:
Daniel Lockyer 2024-06-26 10:57:36 +02:00 committed by Daniel Lockyer
parent 6099a14082
commit 6c07b1cff9

View File

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