Skip to content

MobileFormattingToolbarController always portals into document.body, ignoring portalElements #3304

Closed

Description

@ihordubas99

What’s broken?

Since 0.55, FormattingToolbarController switches to MobileFormattingToolbarController on touch devices while the virtual keyboard is open. The mobile controller hardcodes its portal target:

// packages/react/src/components/FormattingToolbar/MobileFormattingToolbarController.tsx
<PortalElementOverride target={document.body}>

The portalElements map on BlockNoteView has a formattingToolbar key, and the desktop toolbar respects it. The mobile toolbar, and the dropdowns that portal into the same body-level root, ignore it.

This breaks editors rendered inside a shadow root. The BlockNote styles are loaded into the shadow root, but the mobile toolbar ends up in document.body, outside it. The portal root gets the bn-root / bn-mantine classes and theme variables, but no stylesheet matches them there. On iOS and Android the toolbar renders unstyled: bare Mantine buttons, no toolbar background, and it isn't pinned above the keyboard.

What did you expect to happen?

Keep document.body as the default (I understand it avoids the iOS -webkit-overflow-scrolling stacking issue described in the source), but respect portalElements.formattingToolbar, falling back to portalElements.default, when it is set. Then apps can keep the mobile toolbar inside their shadow root or any other styled container.

Steps to reproduce

  1. Render a BlockNoteView inside a shadow root, and load @blocknote/mantine/style.css only into that shadow root (not into the document).
  2. Passing portalElements={{ formattingToolbar: ... }} doesn't help either, since the mobile controller doesn't read it.
  3. Open the page on a touch device, or emulate one (navigator.maxTouchPoints > 0 and (pointer: coarse)), and focus the editor so the virtual keyboard opens.
  4. The mobile formatting toolbar is appended to document.body, outside the shadow root, and renders unstyled.

BlockNote version

0.55.0 (same code in 0.57.0)

Environment

iOS Safari, Android Chrome 156; React 19.3.1, @blocknote/mantine

Additional context

Workaround: we load the BlockNote stylesheet into document.head as well, so the body-level toolbar gets its styles.

Screenshot of the unstyled toolbar on iOS attached.

Image

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 💖

Activity

  1. added
    needs-triage
    on Nov 5, 2026
  2. nperez0111 commented on Nov 5, 2026

    @nperez0111
    Contributor

    Thanks @ihordubas99, we will definitely fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions