From ba2e89dbb35bc18f779f6cdd8de77a9fcb3b7a61 Mon Sep 17 00:00:00 2001 From: j4rviscmd Date: Sun, 29 Mar 2026 16:02:41 +0900 Subject: [PATCH] fix(editor): prevent padding click handler from closing toolbar on button clicks The handleWrapperClick guard only checked for `.bn-editor`, but BlockNote UI elements (formatting toolbar, color picker, menus, etc.) are rendered as siblings of `.bn-editor` inside `.bn-container`. Clicks on these elements would pass the guard, causing the cursor to move to the last block and the selection to clear, which closed the toolbar before the color picker could open. Co-Authored-By: Claude Opus 4.6 --- src/features/editor/ui/Editor.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/features/editor/ui/Editor.tsx b/src/features/editor/ui/Editor.tsx index 53361c0..b9642c8 100644 --- a/src/features/editor/ui/Editor.tsx +++ b/src/features/editor/ui/Editor.tsx @@ -567,10 +567,10 @@ export const Editor = forwardRef(function Editor( * 1. **Locked mode** – when the editor is read-only (`locked` is `true`), * the callback is a no-op so that clicking the padding area does not * steal focus or move the cursor. - * 2. **Inside `.bn-editor`** – if the click originated inside the - * contenteditable region (including any descendant elements), the - * callback returns early and lets the default browser behaviour handle - * focus normally. + * 2. **Inside `.bn-container`** – if the click originated inside the + * BlockNote container (including the editor, toolbars, menus, and other + * UI overlays), the callback returns early and lets the default browser + * behaviour handle focus normally. * * @param e - The React mouse event from the wrapper `
`. */ @@ -578,7 +578,7 @@ export const Editor = forwardRef(function Editor( (e: React.MouseEvent) => { if (locked) return const target = e.target as HTMLElement - if (target.closest('.bn-editor')) return + if (target.closest('.bn-container')) return if (target.closest('[role="dialog"]')) return const lastBlock = editor.document[editor.document.length - 1]