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: Formatting toolbar opening on drop #944

Merged
merged 3 commits into from
Jul 18, 2024
Merged

Conversation

matthewlipski
Copy link
Collaborator

When you drag & drop a block, the editor is blurred and its state is updated. However, the blur gets handled async and so the state updates before the editor has actually been blurred. This is a problem for the formatting toolbar, which updates whenever the editor state does but also needs to know if the editor is blurred to decide whether to show. Like the editor state, it also updates before the editor is blurred, and so it shows up on drop. Additionally, the blur doesn't trigger a state update, only a view update, and so doesn't re-trigger an update on the formatting toolbar.

This PR re-adds the blur event listener to the editor, for the formatting toolbar to update whenever the editor loses focus. This is not totally ideal as it gets updated twice on drop, but I think it's cleaner than delaying the update using a setTimeout instead which is the alternative approach. Accessibility using the keyboard still works with these changes.

Closes #929

Copy link

vercel bot commented Jul 17, 2024

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Jul 17, 2024 2:33pm
blocknote-website ✅ Ready (Inspect) Visit Preview Jul 17, 2024 2:33pm

matthewlipski added a commit that referenced this pull request Jul 18, 2024
@matthewlipski matthewlipski merged commit 1b414c8 into main Jul 18, 2024
4 checks passed
matthewlipski added a commit that referenced this pull request Jul 18, 2024
* WIP fix for formatting toolbar appearing on drop

* Re-added focus event handling for formatting toolbar

* Removed focus handler

* Restricted mouse y-coord to editor bounding box during drag & drop

* Removed blur listener from #944
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Formatting Toolbar is displayed after block is dragged
1 participant