diff --git a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts index 98254c3f..ba97303f 100644 --- a/packages/extension-bubble-menu/src/bubble-menu-plugin.ts +++ b/packages/extension-bubble-menu/src/bubble-menu-plugin.ts @@ -113,25 +113,23 @@ export class BubbleMenuView { } createTooltip() { - if (this.tippy) { + const { element: editorElement } = this.editor.options + const editorIsAttached = !!editorElement.parentElement + + if (this.tippy || !editorIsAttached) { return } - const { element: editorElement } = this.editor.options - - // Wait until editor element is attached to the document - if (editorElement.parentElement) { - this.tippy = tippy(editorElement, { - duration: 0, - getReferenceClientRect: null, - content: this.element, - interactive: true, - trigger: 'manual', - placement: 'top', - hideOnClick: 'toggle', - ...this.tippyOptions, - }) - } + this.tippy = tippy(editorElement, { + duration: 0, + getReferenceClientRect: null, + content: this.element, + interactive: true, + trigger: 'manual', + placement: 'top', + hideOnClick: 'toggle', + ...this.tippyOptions, + }) } update(view: EditorView, oldState?: EditorState) { diff --git a/packages/extension-floating-menu/src/floating-menu-plugin.ts b/packages/extension-floating-menu/src/floating-menu-plugin.ts index 0749d5ca..7fdd21b2 100644 --- a/packages/extension-floating-menu/src/floating-menu-plugin.ts +++ b/packages/extension-floating-menu/src/floating-menu-plugin.ts @@ -99,25 +99,23 @@ export class FloatingMenuView { } createTooltip() { - if (this.tippy) { + const { element: editorElement } = this.editor.options + const editorIsAttached = !!editorElement.parentElement + + if (this.tippy || !editorIsAttached) { return } - const { element: editorElement } = this.editor.options - - // Wait until editor element is attached to the document - if (editorElement.parentElement) { - this.tippy = tippy(editorElement, { - duration: 0, - getReferenceClientRect: null, - content: this.element, - interactive: true, - trigger: 'manual', - placement: 'right', - hideOnClick: 'toggle', - ...this.tippyOptions, - }) - } + this.tippy = tippy(editorElement, { + duration: 0, + getReferenceClientRect: null, + content: this.element, + interactive: true, + trigger: 'manual', + placement: 'right', + hideOnClick: 'toggle', + ...this.tippyOptions, + }) } update(view: EditorView, oldState?: EditorState) {