-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(drag-handle): resolve parent when nodeAt(pos) is null for atom nodes with inline content #7139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…th-inline When pos maps into an atom node that allows inline content, state.doc.nodeAt(pos) may be null. Resolve the position and return the parent
🦋 Changeset detectedLatest commit: cbc0cbd The changes in this PR will be included in the next version bump. This PR includes changesets to release 70 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for tiptap-embed ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a null handling issue in the drag handle extension where nodeAt(pos) can return null for certain edge cases, specifically when dealing with atom nodes that allow inline content.
- Added null check for
nodeafterstate.doc.nodeAt(pos)call - Implemented fallback logic to resolve the parent node using
state.doc.resolve(pos) - Added changeset documentation explaining the fix
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/extension-drag-handle/src/helpers/findNextElementFromCursor.ts | Added null check and fallback logic to handle cases where nodeAt(pos) returns null by resolving the parent node instead |
| .changeset/lazy-impalas-burn.md | Added changeset documentation for the bug fix |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
@tiptap/core
@tiptap/extension-blockquote
@tiptap/extension-bubble-menu
@tiptap/extension-bold
@tiptap/extension-bullet-list
@tiptap/extension-code
@tiptap/extension-code-block
@tiptap/extension-code-block-lowlight
@tiptap/extension-collaboration
@tiptap/extension-collaboration-caret
@tiptap/extension-color
@tiptap/extension-details
@tiptap/extension-document
@tiptap/extension-drag-handle
@tiptap/extension-drag-handle-react
@tiptap/extension-drag-handle-vue-2
@tiptap/extension-drag-handle-vue-3
@tiptap/extension-file-handler
@tiptap/extension-emoji
@tiptap/extension-floating-menu
@tiptap/extension-hard-break
@tiptap/extension-font-family
@tiptap/extension-heading
@tiptap/extension-highlight
@tiptap/extension-horizontal-rule
@tiptap/extension-image
@tiptap/extension-invisible-characters
@tiptap/extension-italic
@tiptap/extension-link
@tiptap/extension-mathematics
@tiptap/extension-list
@tiptap/extension-mention
@tiptap/extension-ordered-list
@tiptap/extension-node-range
@tiptap/extension-paragraph
@tiptap/extension-strike
@tiptap/extension-subscript
@tiptap/extension-superscript
@tiptap/extension-table
@tiptap/extension-table-of-contents
@tiptap/extension-text
@tiptap/extension-text-align
@tiptap/extension-text-style
@tiptap/extension-typography
@tiptap/extension-underline
@tiptap/extension-unique-id
@tiptap/extension-youtube
@tiptap/extensions
@tiptap/html
@tiptap/markdown
@tiptap/react
@tiptap/pm
@tiptap/starter-kit
@tiptap/suggestion
@tiptap/static-renderer
@tiptap/vue-3
@tiptap/vue-2
@tiptap/extension-dropcursor
@tiptap/extension-character-count
@tiptap/extension-focus
@tiptap/extension-gapcursor
@tiptap/extension-history
@tiptap/extension-list-item
@tiptap/extension-list-keymap
@tiptap/extension-placeholder
@tiptap/extension-table-cell
@tiptap/extension-table-header
@tiptap/extension-table-row
@tiptap/extension-task-item
@tiptap/extension-task-list
commit: |
|
Review the "Checklist" section of the PR description |
|
Reviewed the checklist |
Changes Overview
Fix
findElementNextToCoordsso that when it maps a top-level DOM block to a ProseMirror position andstate.doc.nodeAt(pos)returnsnull(for example, when the position falls inside an atom node that allows inline content), it falls back to the containing parent node instead. This ensures the drag handle targets the correct block element in those cases.Implementation Details
findElementNextToCoords, handle the case wherestate.doc.nodeAt(pos)isnull.state.doc.resolve(pos)and derive the parent node from the resolved position.resultNodeand useresolvedPos.start()as the position for the block.Testing Done
Manually verified drag-handle behavior on Notion-like template
Verification Steps
Additional Notes
Screen.Recording.2025-12-05.at.01.mp4
Checklist
Related Issues