Skip to content
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

fix: Blocks being deleted when dropped outside editor container #1443

Merged
merged 3 commits into from
Feb 19, 2025

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented Feb 17, 2025

This PR fixes an issue with block drag & drop that was introduced in PR #1413. The code block

if (this.isDragOrigin && !this.pmView.dom.contains(event.target as Node)) {
  setTimeout(() => this.pmView.dispatch(this.pmView.state.tr.deleteSelection()), 0);
}

is supposed to check if the dragged blocks come from the same editor instance as the handler, but are being dropped in a different editor instance. This is wrong as !this.pmView.dom.contains(event.target as Node) can be any element outside the current editor instance, and not necessarily another editor.

And so, all that ends up happening when a drop event occurs outside the current editor instance is that the selection is deleted.

Closes #1396
Closes #1435

Copy link

vercel bot commented Feb 17, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Feb 19, 2025 4:01pm
blocknote-website ✅ Ready (Inspect) Visit Preview Feb 19, 2025 4:01pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants