Skip to content

Commit c4a2d9c

Browse files
committed
docs(core): explain what the parent hop in isWithinEditor is actually for
The previous wording said it covers "UI rendered as a sibling of the content" without saying which UI that is — and BlockNote's own default UI is entirely portalled (a mounted editor's container has exactly two children: the content element and the portal), so on its own that justification doesn't hold up. The real case is UI the host app passes as `BlockNoteView` children, which React renders as siblings of the content element. The shipped "Static Formatting Toolbar" example is exactly that: `<FormattingToolbar />` rendered inline rather than through a controller, putting eleven focusable buttons next to the content. Without the hop, focusing one of them reads as "outside the editor", which would dismiss the mobile toolbar mid-interaction and trip the side menu's click-outside check.
1 parent cdb2a5d commit c4a2d9c

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

‎packages/core/src/editor/BlockNoteEditor.ts‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,8 +799,15 @@ export class BlockNoteEditor<
799799
* elements like menus and toolbars).
800800
*
801801
* The first check deliberately starts one level up, at the content area's
802-
* *parent*, so that UI rendered as a sibling of the content (rather than
803-
* portalled) also counts as part of the editor.
802+
* *parent*. BlockNote's own default UI is entirely portalled, so that hop
803+
* isn't for its sake — it's for UI the host app renders as `BlockNoteView`
804+
* children, which React places as siblings of the content element. The
805+
* "Static Formatting Toolbar" example does exactly that: it renders
806+
* `<FormattingToolbar />` inline instead of through a controller, putting
807+
* a dozen focusable buttons next to the content. Without the hop, focusing
808+
* one of them would read as "outside the editor" — dismissing the mobile
809+
* toolbar mid-interaction, and tripping the side menu's click-outside
810+
* check.
804811
*
805812
* That makes the result depend on where the editor is mounted, because
806813
* `editor.mount(element)` turns `element` itself into the content area —

0 commit comments

Comments
 (0)