Skip to content

Multi-character suggestion triggers only open at the start of a text block #2971

Description

@ntietje1

EDIT: I realize this was fixed by fix: suggestion menu behaviour (BLO-1283, BLO-955) #2930

What’s broken?

Suggestion menus with a multi-character trigger, such as [[, do not open when other text appears earlier in the same text block:

  • Typing [[ at the beginning of an empty paragraph opens the suggestion menu.
  • Typing Something [[ does not open it.

The problem is in SuggestionMenu's handleTextInput implementation. When the final character of a multi-character trigger is entered, the handler reads triggerCharacter.length existing characters and then appends the newly entered character:

What did you expect to happen?

A multi-character suggestion trigger should open wherever the trigger is typed in an eligible text block, regardless of what text appears before it.

Steps to reproduce

  1. Configure a SuggestionMenuController with a multi-character trigger:
<SuggestionMenuController
   triggerCharacter="[["
   getItems={getItems}
/>
  1. Focus an empty paragraph and type [[.
  2. Observe that the suggestion menu opens.
  3. Close the menu or create another paragraph.
  4. Type test [[.
  5. Observe that the suggestion menu does not open.

BlockNote version

v0.46.2

Environment

Firefox/Chromium on Windows with React 19

Additional context

No response

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 💖

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageIssue has not yet been reviewed or classified by maintainers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions