diff --git a/packages/tiptap/src/Plugins/FloatingMenu.js b/packages/tiptap/src/Plugins/FloatingMenu.js index 2441b1d64..de3a04ed1 100644 --- a/packages/tiptap/src/Plugins/FloatingMenu.js +++ b/packages/tiptap/src/Plugins/FloatingMenu.js @@ -66,7 +66,14 @@ class Menu { return } - const editorBoundings = this.options.element.offsetParent.getBoundingClientRect() + const parent = this.options.element.offsetParent + + if (!parent) { + this.hide() + return + } + + const editorBoundings = parent.getBoundingClientRect() const cursorBoundings = view.coordsAtPos(state.selection.anchor) const top = cursorBoundings.top - editorBoundings.top diff --git a/packages/tiptap/src/Plugins/MenuBubble.js b/packages/tiptap/src/Plugins/MenuBubble.js index 2a43992bd..1e2f9e707 100644 --- a/packages/tiptap/src/Plugins/MenuBubble.js +++ b/packages/tiptap/src/Plugins/MenuBubble.js @@ -111,7 +111,14 @@ class Menu { const end = coordsAtPos(view, to, true) // The box in which the tooltip is positioned, to use as base - const box = this.options.element.offsetParent.getBoundingClientRect() + const parent = this.options.element.offsetParent + + if (!parent) { + this.hide() + return + } + + const box = parent.getBoundingClientRect() const el = this.options.element.getBoundingClientRect() // Find a center-ish x position from the selection endpoints (when