Skip to content

Floating comment button stops working for non-editors #2257

@jmfieldman

Description

@jmfieldman

Describe the bug
The comment button in the formatting toolbar stop appearing when the BlockNoteView editable state becomes false.

To Reproduce
You can reproduce this in the latest stackblitz from your demo: https://stackblitz.com/github/TypeCellOS/BlockNote/tree/main/examples/07-collaboration/06-comments-with-sidebar?file=src%2FApp.tsx

  • The user starts as an editor.
  • Highlight text and see the floating bar.
  • Switch to a commenter user
  • Highlight text, and you will not see any floating buttons (what I expect: still see the comment button)

Now, edit App.tsx and change

const [activeUser, setActiveUser] = useState<MyUserType>(HARDCODED_USERS[0]);

to

const [activeUser, setActiveUser] = useState<MyUserType>(HARDCODED_USERS[2]);

So that it starts with a commenter user.

Reload the page

After reloading, the initial commenter user DOES see the add comment button when highlighting text. If you switch to an editor user and back to a commenter, the add comment button does not appear again.

Expected Behavior

The add comment button is always visible to all users even if the editable state is false.

Misc

This may be affected by reactStrictMode -- when I set it to false in my config this issue springs up more often. Setting it to true fixes the issue in some of my own cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions