Skip to content

useSelectedBlocks / getTextCursorPosition report the block after a gap cursor #3421

In review

Description

@ihordubas99

What’s broken?

When the selection is a gap cursor (e.g. between two blocks without inline content, such as images or custom blocks with content: "none"), BlockNote treats the block after the gap cursor as the one holding the cursor: getTextCursorPosition().block and useSelectedBlocks() return that block. A custom block that highlights itself when it is selected therefore looks selected while the cursor is actually above it.

#3361 fixed Enter at a gap cursor, but not what these APIs report.

What did you expect to happen?

With a gap cursor, no block should be reported as selected (or the API should expose that the selection is a gap cursor), since the cursor is between blocks, not inside one.

Steps to reproduce

  1. Insert two images one after the other
  2. Put the cursor at the end of the paragraph above and press ArrowDown until the gap cursor shows between the two images
  3. Log editor.getTextCursorPosition().block or useSelectedBlocks(editor)
  4. See the second image reported as the cursor block

BlockNote version

v0.55.0

Environment

No response

Additional context

We hit this with custom blocks (content: "none") that draw their own selection outline based on useSelectedBlocks; with a gap cursor between two of them, the lower one gets outlined. We work around it by checking whether the selection is a gap cursor.

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 25, 2026
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