Skip to content

fix: Formatting toolbar appearance on fade out #642

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

Closed
wants to merge 1 commit into from

Conversation

matthewlipski
Copy link
Collaborator

Because formatting toolbar buttons manage their own state, they check whether they should be shown based on the block that the text cursor is in. This can be a problem if the user clicks a block of a different type to close the toolbar, as it can cause the toolbar state to change as it's fading out, which looks bad. This PR fixes that by making the plugin figure out which block(s) are selected instead, and including them in the plugin state for the toolbar buttons.

The difference between this approach and using useSelectedBlocks is that the plugin will NOT update the selected blocks if state.show is false, so the selected blocks are only updated when the formatting toolbar itself is shown/updated.

This is similar to how & why we pass the hovered block in the side menu/drag handle menu, so I think this pattern makes sense.

Copy link

vercel bot commented Mar 13, 2024

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

Name Status Preview Updated (UTC)
blocknote ✅ Ready (Inspect) Visit Preview Mar 13, 2024 3:28pm
blocknote-website ✅ Ready (Inspect) Visit Preview Mar 13, 2024 3:28pm

@matthewlipski
Copy link
Collaborator Author

Fixed with #645

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.

1 participant