Skip to content

fix(core): keep the formatting toolbar hidden when focus returns to editor UI - #3187

Merged
YousefED merged 1 commit into
mainfrom
fix/formatting-toolbar-ui-focus
Oct 13, 2026
Merged

YousefED merged 1 commit into
mainfrom
fix/formatting-toolbar-ui-focus

Conversation

@YousefED

@YousefED YousefED commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #3186

Problem

The editor has a selection, and focus is outside the editor. The user clicks a drag handle. The formatting toolbar shows again, over the drag handle menu.

The focus handler from #3031 counts the editor's UI as part of the editor. Focus that moves from outside onto the drag handle shows the toolbar for the old selection.

Fix

When focus comes back, show the toolbar only if the content area has focus (editor.isFocused()). The pointerup handler in the same file already uses this check.

Tests

New test in draghandle.test.tsx: select text, move focus outside the editor, click a drag handle. The toolbar must stay hidden. The test fails without the fix in chromium, firefox and webkit.

Summary by CodeRabbit

  • Bug Fixes
    • The formatting toolbar now responds to focus changes only when focus is within the editor content. Returning focus to editor controls without focusing the content no longer causes the toolbar to appear—for example, after clicking outside the editor and opening a drag-handle menu. This keeps the toolbar hidden until the editor content itself receives focus.

…ditor UI

When focus came back from outside the editor into its UI (e.g. the drag
handle), the toolbar showed again for the old selection, over the drag
handle menu. Show it again only when the content area has focus.

Closes #3186
@vercel

vercel Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
blocknote Ready Ready Preview Oct 13, 2026 7:32am UTC
blocknote-website Ready Ready Preview Oct 13, 2026 7:32am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f41543b9-d938-4ad7-b79c-a3bea59d1a20
📥 Commits

Reviewing files that changed from the base of the PR and between ae1348b and ff8f605.

📒 Files selected for processing (2)
  • packages/core/src/extensions/FormattingToolbar/FormattingToolbar.ts
  • tests/src/end-to-end/draghandle/draghandle.test.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The formatting toolbar now re-evaluates visibility on focus changes only when the editor content has focus. An end-to-end regression test checks that the toolbar stays hidden when the drag-handle menu opens after the editor loses focus.

Changes: Formatting toolbar focus

Layer / File(s) Summary
Guard toolbar visibility on focus changes
packages/core/src/extensions/FormattingToolbar/FormattingToolbar.ts, tests/src/end-to-end/draghandle/draghandle.test.tsx
The focus-change handler calls shouldShow() only when the editor has focus. The regression test selects text, blurs the editor, opens a drag-handle menu, and checks that the formatting toolbar stays hidden.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: nperez0111

Merge Risk: ⚪ Minimal · up to ff8f6

The toolbar focus guard addresses the reported drag-handle interaction. No actionable issue is identified before normal checks.

Pre-merge checks · Passed 5
Passed Passed checks (5 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: keeping the formatting toolbar hidden when focus returns to editor UI.
Description check Passed The description explains the problem, root cause, fix, affected behavior, linked issue, and regression test coverage. It omits several template sections, including Impact, Screenshots/Video, Checklist…
Linked Issues check Passed Issue #3186 requires the formatting toolbar to remain hidden when the editor content has lost focus and the drag-handle menu opens. FormattingToolbar.ts now calls shouldShow() on focus return only…
Out of Scope Changes check Passed The source change is limited to focus-based formatting-toolbar visibility. The added end-to-end test covers the #3186 regression. The import changes support that test. No unrelated implementation or t…
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit watched the toolbar hide,
Then checked the editor’s focus inside.
The drag handle opened; the menu stayed clear,
No toolbar returned to hover near.
The rabbit thumped: “That test is dear!”

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@blocknote/ariakit

npm i https://pkg.pr.new/@blocknote/ariakit@3187

@blocknote/code-block

npm i https://pkg.pr.new/@blocknote/code-block@3187

@blocknote/core

npm i https://pkg.pr.new/@blocknote/core@3187

@blocknote/diagram-block

npm i https://pkg.pr.new/@blocknote/diagram-block@3187

@blocknote/mantine

npm i https://pkg.pr.new/@blocknote/mantine@3187

@blocknote/math-block

npm i https://pkg.pr.new/@blocknote/math-block@3187

@blocknote/react

npm i https://pkg.pr.new/@blocknote/react@3187

@blocknote/server-util

npm i https://pkg.pr.new/@blocknote/server-util@3187

@blocknote/shadcn

npm i https://pkg.pr.new/@blocknote/shadcn@3187

@blocknote/xl-ai

npm i https://pkg.pr.new/@blocknote/xl-ai@3187

@blocknote/xl-docx-exporter

npm i https://pkg.pr.new/@blocknote/xl-docx-exporter@3187

@blocknote/xl-email-exporter

npm i https://pkg.pr.new/@blocknote/xl-email-exporter@3187

@blocknote/xl-multi-column

npm i https://pkg.pr.new/@blocknote/xl-multi-column@3187

@blocknote/xl-odt-exporter

npm i https://pkg.pr.new/@blocknote/xl-odt-exporter@3187

@blocknote/xl-pdf-exporter

npm i https://pkg.pr.new/@blocknote/xl-pdf-exporter@3187

@blocknote/xl-typst-exporter

npm i https://pkg.pr.new/@blocknote/xl-typst-exporter@3187

commit: ff8f605

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-10-13 07:50 UTC

@YousefED
YousefED merged commit 72e1e77 into main Oct 13, 2026
35 of 37 checks passed
@YousefED
YousefED deleted the fix/formatting-toolbar-ui-focus branch October 13, 2026 07:50

This branch was successfully deployed

2 active deployments
Preview – blocknote-website — ff8f6057 Deployed Oct 13, 2026 by vercel[bot]
Preview – blocknote — ff8f6057 Deployed Oct 13, 2026 by vercel[bot]
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 reappears over the drag handle menu when the editor was not focused (regression in 0.55.0)

1 participant