You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Side menu "Add block" (+) not usable with keyboard (hover-only, Tab captured, Enter/Space) #2854
The “Add block” (+) and the 6 dots optionbutton in the left margin:
Mostly appears on mouse hover : little or no access with keyboard only.
Tab rarely reaches it: the editor captures Tab for indenting blocks, with no exception for the side menu
Enter / Space often don’t open the insert menu when the handler is on the icon instead of the actual button.
What did you expect to happen?
The + button should appear and be reachable without mouse hover, Tab should focus it when the side menu is visible, and Enter/Space should open the insert menu like a click, including with a screen reader.
Steps to reproduce
Open a document without hovering the margin.
Move the caret with the keyboard : the + is often missing.
If it appears (e.g. after hover), press Tab : focus often goes on and then disapears
If focus is on +, Enter or Space : insert menu doesn’t always open.
BlockNote version
No response
Environment
No response
Additional context
Show the side menu when the caret / selection is in a block (not only on mousemove), and don’t hide it on Tab / arrow keys.
Don’t capture Tab for nesting while the side menu is shown
Attach onClick to SideMenu.Button, not only the inner icon.
Contribution
I'd be interested in contributing a fix for this issue
Sponsor
I'm a sponsor and would appreciate if you could look into this sooner than later 💖
Show the side menu when the caret / selection is in a block (not only on mousemove), and don’t hide it on Tab / arrow keys.
Don’t capture Tab for nesting while the side menu is shown
Would mean Tab can never be used for indentation, as there's always a menu shown. I'm not sure this is desirable
Some alternatives:
Use Shift+F10 (the context menu shortcut) to open the menu? (effort: low-medium)
Use Escape to go into "block highlight mode" (this doesn't exist yet), from which Tab can be used to access the side menu
Step 3 of this issue reproduces every time in a default editor, and the cause is narrower than Tab being captured: Tab does reach the side menu, but only a static HTML copy of it that has no event handlers and is removed 250 ms later, which drops focus to document.body.
Versions: @blocknote/core, @blocknote/react and @blocknote/mantine 0.57.0 (0.56.0 behaves the same), React 19.3.0, @floating-ui/react 0.27.20, Chrome 156 on macOS. It also reproduces on https://www.blocknotejs.org/examples/basic/minimal.
Steps to reproduce
Render a default editor: useCreateBlockNote() with three paragraphs as initial content, BlockNoteView from @blocknote/mantine, no other options. Put a focusable button before it and one after it in the page.
Move the pointer onto the first paragraph's text, so the side menu shows, and click there to put the caret in it. Leave the pointer where it is.
Press Tab once.
Read document.activeElement right away, and again 400 ms later.
Expected: focus moves to the button after the editor, as it does when the side menu is not showing (Tab from the button before the editor into it, then Tab again, without touching the pointer).
Actual, in each of seven runs:
Right after Tab, focus is on a <button aria-label="Add block"> inside .bn-side-menu, at the live button's position, in a wrapper fading from opacity 1 to 0. React did not render that element: it has no __reactProps$ key.
Enter and Space on it do nothing. No suggestion menu opens and the document is unchanged.
About 250 ms after the Tab the element is removed and document.activeElement is document.body. The next Tab goes to the button after the editor.
The same happens after a selection made with the pointer. Double-click a word in the first paragraph, so the formatting toolbar shows while the pointer stays over the block, and press Tab. With tabBehavior at its default, "prefer-navigate-ui", that Tab is meant to move into the toolbar, and after a selection made with Shift+End and no pointer it does, onto the block type select. With the side menu shown it lands on the side menu's copy instead and falls to document.body 250 ms later; the next Tab lands on the formatting toolbar's own closing copy, by then fading out itself, and falls to document.body in turn; the third Tab leaves the editor. The toolbar's live controls are never reached.
What works as expected: in the second paragraph Tab nests the block and focus stays in the editor; Shift+Tab from the first paragraph goes to the button before the editor; and with no pointer over a block, Tab leaves the editor normally.
The mechanism
Tab reaches the browser only when the editor declines it. handleTab() returns false while a formatting toolbar or file panel is open, and otherwise returns what nestBlock() or unnestBlock() returns, which is false for a block that cannot be nested, such as the first block of its group (KeyboardShortcutsExtension.ts#L1019-L1038):
functionhandleTab(shift: boolean){const{ editor, tabBehavior }=options;if(tabBehavior!=="prefer-indent"&&(editor.getExtension(FormattingToolbarExtension)?.store.state||editor.getExtension(FilePanelExtension)?.store.state!==undefined)){// Let the browser navigate into and out of an open toolbar.returnfalse;}returnshift ? unnestBlock(editor) : nestBlock(editor);}
Before ProseMirror sees the key, the side menu's capture-phase keydown listener on the editor's root (the document, or the shadow root the editor is mounted in) hides the menu on any key while the editor is focused, Tab included (SideMenu.ts#L361-L371):
// Hides the menu whenever the user types.root.addEventListener("keydown",()=>{if(store.state?.show&&editor.isFocused()){clearIntent();hideMenu();}},{ signal,capture: true},);
React commits that change before the browser performs Tab's default action. The store reaches React through useSyncExternalStore (useStore.ts#L18-L30), whose updates render synchronously, and in the browser a MutationObserver saw the live menu removed and the copy added before a bubble-phase keydown listener on document ran. In that commit SideMenuController passes BlockPopover no block id, so BlockPopover passes no children (SideMenuController.tsx#L159-L168, BlockPopover.tsx#L41-L45), and GenericPopover, its transition status now "close", renders the markup it stored while the menu was open through dangerouslySetInnerHTML (GenericPopover.tsx#L213-L230, #L251-L269):
The portal is appended to the element wrapping the editor, .bn-container in the default layout (PortalElementOverride.tsx#L39-L48). It follows the editable there, and with a pointer selection it also comes before the formatting toolbar's portal, which opened after it. So the copy's Add block button is the first tabbable element after the editable, and the browser's default action focuses it: a <button> parsed from a string, with none of React's handlers.
The copy stays mounted while useTransitionStyles() reports isMounted, which turns false 250 ms after open does, @floating-ui/react's default, as neither SideMenuController nor BlockPopover passes a duration (GenericPopover.tsx#L150-L157, #L232-L234). When it unmounts, the focused button goes with it and focus falls to document.body.
The formatting toolbar's dead stop in the second case is the same GenericPopover closing copy, so the stray tab stop is not specific to the side menu.
The issue's point 3 also still holds in 0.57.0. When the live side menu does get focus (pointer resting on a block, focus on the button after the editor, Shift+Tab twice), Space on the drag handle opens its menu, but Enter on Add block does nothing, because AddBlockButton attaches onClick to the icon rather than to the button (AddBlockButton.tsx#L55-L61).
What this project does meanwhile
This is the Drupal BlockNote module. Its js/src/menus.tsx always supplies its own side menu component, wrapped so that a useLayoutEffect with no dependency list sets tabindex="-1" on both of the side menu's buttons before any passive effect runs, in particular before GenericPopover's own effect stores the markup it will copy. Tab then passes over the menu and over the copy alike, because the copy inherits the attribute. Nothing loses its only route: the module's Add block button opens the same slash menu that typing "/" opens, and every item the drag handle menu offers is also on the block menu Alt+F10 opens (see ADR 0011).
What this asks for
One of, in order of preference:
Give the side menu's two buttons tabIndex={-1} in SideMenu.tsx itself, so Tab always passes over them and over the copy made from their markup, and document a keyboard route to the functions they hold (or note that host applications are expected to provide one, as this module does). This keeps the side menu out of Tab's path, as the comment above prefers.
Skip hiding the menu in the keydown listener for the Tab key specifically, or call preventDefault() there and move focus explicitly, so a hidden menu never leaves a stray tab stop behind. Tab would then reach the live menu, where Add block also needs its onClick moved to the button.
Render GenericPopover's closing copy with the inert attribute, so no closing popover can take focus during the 250 ms it exists. Simulated in the reproduction, with a MutationObserver setting inert on the copy's wrapper as it was added, Tab from the first paragraph went to the button after the editor, and Tab after a pointer selection went to the formatting toolbar's block type select, and focus stayed in both places. If GenericPopover re-parses innerHTML while closing, which violates a strict CSP (style-src without 'unsafe-inline') #3209's cloned-node snapshot lands, the wrapper the clones are appended to is where the attribute would go.
Remaining tasks
Confirm which of the three fixes above, if any, the maintainers would accept, since only they can say which changes least about the side menu's contract.
The steps above are ready cases for the keyboard and focus tests Accessibility test suite and regression testing #3208 plans: with the side menu shown and the caret in the first block, one Tab should land on whatever follows the editor and stay there; with the side menu shown and a word selected, one Tab should land in the formatting toolbar.
Check Firefox and Safari; only Chrome was tested.
AI use: I maintain the BlockNote module for Drupal. Its code, tests and documentation, this comment and the reproduction behind it were made with AI coding agents that I direct.
Activity
YousefED commentedon Jun 17, 2026
@Ovgodd the combination of this:
Would mean Tab can never be used for indentation, as there's always a menu shown. I'm not sure this is desirable
Some alternatives:
Interesting to discuss further
NodarDavituri commentedon Oct 30, 2026
Step 3 of this issue reproduces every time in a default editor, and the cause is narrower than Tab being captured: Tab does reach the side menu, but only a static HTML copy of it that has no event handlers and is removed 250 ms later, which drops focus to
document.body.Versions:
@blocknote/core,@blocknote/reactand@blocknote/mantine0.57.0 (0.56.0 behaves the same), React 19.3.0,@floating-ui/react0.27.20, Chrome 156 on macOS. It also reproduces on https://www.blocknotejs.org/examples/basic/minimal.Steps to reproduce
useCreateBlockNote()with three paragraphs as initial content,BlockNoteViewfrom@blocknote/mantine, no other options. Put a focusable button before it and one after it in the page.document.activeElementright away, and again 400 ms later.Expected: focus moves to the button after the editor, as it does when the side menu is not showing (Tab from the button before the editor into it, then Tab again, without touching the pointer).
Actual, in each of seven runs:
<button aria-label="Add block">inside.bn-side-menu, at the live button's position, in a wrapper fading from opacity 1 to 0. React did not render that element: it has no__reactProps$key.document.activeElementisdocument.body. The next Tab goes to the button after the editor.The same happens after a selection made with the pointer. Double-click a word in the first paragraph, so the formatting toolbar shows while the pointer stays over the block, and press Tab. With
tabBehaviorat its default,"prefer-navigate-ui", that Tab is meant to move into the toolbar, and after a selection made with Shift+End and no pointer it does, onto the block type select. With the side menu shown it lands on the side menu's copy instead and falls todocument.body250 ms later; the next Tab lands on the formatting toolbar's own closing copy, by then fading out itself, and falls todocument.bodyin turn; the third Tab leaves the editor. The toolbar's live controls are never reached.What works as expected: in the second paragraph Tab nests the block and focus stays in the editor; Shift+Tab from the first paragraph goes to the button before the editor; and with no pointer over a block, Tab leaves the editor normally.
The mechanism
Tab reaches the browser only when the editor declines it.
handleTab()returnsfalsewhile a formatting toolbar or file panel is open, and otherwise returns whatnestBlock()orunnestBlock()returns, which isfalsefor a block that cannot be nested, such as the first block of its group (KeyboardShortcutsExtension.ts#L1019-L1038):Before ProseMirror sees the key, the side menu's capture-phase
keydownlistener on the editor's root (the document, or the shadow root the editor is mounted in) hides the menu on any key while the editor is focused, Tab included (SideMenu.ts#L361-L371):React commits that change before the browser performs Tab's default action. The store reaches React through
useSyncExternalStore(useStore.ts#L18-L30), whose updates render synchronously, and in the browser aMutationObserversaw the live menu removed and the copy added before a bubble-phasekeydownlistener ondocumentran. In that commitSideMenuControllerpassesBlockPopoverno block id, soBlockPopoverpasses no children (SideMenuController.tsx#L159-L168, BlockPopover.tsx#L41-L45), andGenericPopover, its transition status now"close", renders the markup it stored while the menu was open throughdangerouslySetInnerHTML(GenericPopover.tsx#L213-L230, #L251-L269):The portal is appended to the element wrapping the editor,
.bn-containerin the default layout (PortalElementOverride.tsx#L39-L48). It follows the editable there, and with a pointer selection it also comes before the formatting toolbar's portal, which opened after it. So the copy's Add block button is the first tabbable element after the editable, and the browser's default action focuses it: a<button>parsed from a string, with none of React's handlers.The copy stays mounted while
useTransitionStyles()reportsisMounted, which turnsfalse250 ms afteropendoes,@floating-ui/react's default, as neitherSideMenuControllernorBlockPopoverpasses a duration (GenericPopover.tsx#L150-L157, #L232-L234). When it unmounts, the focused button goes with it and focus falls todocument.body.The formatting toolbar's dead stop in the second case is the same
GenericPopoverclosing copy, so the stray tab stop is not specific to the side menu.The issue's point 3 also still holds in 0.57.0. When the live side menu does get focus (pointer resting on a block, focus on the button after the editor, Shift+Tab twice), Space on the drag handle opens its menu, but Enter on Add block does nothing, because
AddBlockButtonattachesonClickto the icon rather than to the button (AddBlockButton.tsx#L55-L61).What this project does meanwhile
This is the Drupal BlockNote module. Its
js/src/menus.tsxalways supplies its own side menu component, wrapped so that auseLayoutEffectwith no dependency list setstabindex="-1"on both of the side menu's buttons before any passive effect runs, in particular beforeGenericPopover's own effect stores the markup it will copy. Tab then passes over the menu and over the copy alike, because the copy inherits the attribute. Nothing loses its only route: the module's Add block button opens the same slash menu that typing "/" opens, and every item the drag handle menu offers is also on the block menu Alt+F10 opens (see ADR 0011).What this asks for
One of, in order of preference:
tabIndex={-1}inSideMenu.tsxitself, so Tab always passes over them and over the copy made from their markup, and document a keyboard route to the functions they hold (or note that host applications are expected to provide one, as this module does). This keeps the side menu out of Tab's path, as the comment above prefers.keydownlistener for the Tab key specifically, or callpreventDefault()there and move focus explicitly, so a hidden menu never leaves a stray tab stop behind. Tab would then reach the live menu, where Add block also needs itsonClickmoved to the button.GenericPopover's closing copy with theinertattribute, so no closing popover can take focus during the 250 ms it exists. Simulated in the reproduction, with aMutationObserversettinginerton the copy's wrapper as it was added, Tab from the first paragraph went to the button after the editor, and Tab after a pointer selection went to the formatting toolbar's block type select, and focus stayed in both places. If GenericPopover re-parses innerHTML while closing, which violates a strict CSP (style-src without 'unsafe-inline') #3209's cloned-node snapshot lands, the wrapper the clones are appended to is where the attribute would go.Remaining tasks
AI use: I maintain the BlockNote module for Drupal. Its code, tests and documentation, this comment and the reproduction behind it were made with AI coding agents that I direct.