Skip to content

Commit

Permalink
fix(bubble-menu): prevent null pointer exception in BubbleMenu (#5842)
Browse files Browse the repository at this point in the history
  • Loading branch information
felixgabler authored Nov 19, 2024
1 parent 2ea807d commit 1959eb5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-hats-thank.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tiptap/extension-bubble-menu": patch
---

Fix a potential null pointer exception
14 changes: 8 additions & 6 deletions packages/extension-bubble-menu/src/bubble-menu-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,16 @@ export class BubbleMenuView {
if (isNodeSelection(state.selection)) {
let node = view.nodeDOM(from) as HTMLElement

const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector('[data-node-view-wrapper]')
if (node) {
const nodeViewWrapper = node.dataset.nodeViewWrapper ? node : node.querySelector('[data-node-view-wrapper]')

if (nodeViewWrapper) {
node = nodeViewWrapper.firstChild as HTMLElement
}
if (nodeViewWrapper) {
node = nodeViewWrapper.firstChild as HTMLElement
}

if (node) {
return node.getBoundingClientRect()
if (node) {
return node.getBoundingClientRect()
}
}
}

Expand Down

0 comments on commit 1959eb5

Please sign in to comment.