Skip to content

fix: only treat editor as collaborative when awareness is non-null#368

Open
gularsson wants to merge 1 commit into
mainfrom
fix/collab-detection-requires-awareness
Open

fix: only treat editor as collaborative when awareness is non-null#368
gularsson wants to merge 1 commit into
mainfrom
fix/collab-detection-requires-awareness

Conversation

@gularsson

Copy link
Copy Markdown
Contributor

A Y.XmlText value with the awareness prop key present but null/undefined (e.g. a local-only draft with no peers) was flagged collaborative, which mounts the remote-cursor overlay. withCursors then stored a falsy awareness, so CursorEditor.isCursorEditor returned false and useRemoteCursorOverlayPositions threw "Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor".

Require a non-null awareness in both isTextbitRootCollaborationProps and isSlateContainerCollaborationProps so the collaborative flag and the withCursors attachment agree. A peerless Yjs value now renders as a plain Yjs editor with no cursor overlay.

Adds a regression test covering both the null-awareness and real-awareness paths.

A Y.XmlText value with the `awareness` prop key present but null/undefined
(e.g. a local-only draft with no peers) was flagged collaborative, which
mounts the remote-cursor overlay. withCursors then stored a falsy awareness,
so CursorEditor.isCursorEditor returned false and useRemoteCursorOverlayPositions
threw "Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor".

Require a non-null awareness in both isTextbitRootCollaborationProps and
isSlateContainerCollaborationProps so the collaborative flag and the
withCursors attachment agree. A peerless Yjs value now renders as a plain
Yjs editor with no cursor overlay.

Adds a regression test covering both the null-awareness and real-awareness paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant