Skip to content

RTC: Fix collaborator cursor rendering in table cells#77276

Open
karthikeya-io wants to merge 3 commits intoWordPress:trunkfrom
karthikeya-io:fix/collaborator-cursor-do-not-render-in-table-cells
Open

RTC: Fix collaborator cursor rendering in table cells#77276
karthikeya-io wants to merge 3 commits intoWordPress:trunkfrom
karthikeya-io:fix/collaborator-cursor-do-not-render-in-table-cells

Conversation

@karthikeya-io
Copy link
Copy Markdown
Contributor

@karthikeya-io karthikeya-io commented Apr 13, 2026

What?

Closes #76812

This PR fixes an issue where collaborator cursors fail to render in Table block cells during a Real-Time Collaboration (RTC) session.

Why?

  • Depth Failure: To get the block Y.Map the code checked 2 levels: Y.Text -> attributes Y.Map -> block Y.Map. While this works for other blocks, Table text is buried much deeper (inside Rows and Cells). The original logic would stop too early, fail to find the block ID, and return null.
  • No Cell Identity: The individual Table cells didn't have a unique ID in the HTML (No identifier). This meant the cursor overlay had no way to know which cell a user was typing in.
  • Offset Errors: Searching the entire table instead of a specific cell caused character counts to shift, making cursors appear in the wrong position or vanish

How?

Updated the selection flow to handle deep nesting:

  • In post-editor-awareness.ts replaced the fixed 2-level check with a while loop. This loop walks up the data tree until it finds the block ID.
  • Added a unique identifier to each Table cell's RichText component. This adds a data-wp-block-attribute-key to the HTML so the cell can be identified.
  • Added function getYjsValueByPath to get the Y.Text object for that specific cell using the attributetKey like body[0].cells[1].content.
  • Updated the rendering logic in cursor-dom-utils.ts to use the attributeKey. Instead of searching the whole table, it now jumps directly to the specific cell element before counting characters.
  • Updated the ResolvedSelection type and the selection resolver to include the attributeKey, ensuring the cell's address is passed correctly.

Testing Instructions

  1. Open a post in two different browser windows.
  2. Add a Table block and create a few rows and columns.
  3. In Window A, click into any cell and start typing.
  4. Verify: In Window B, the colored cursor for User A should appear exactly in the correct cell.
  5. Move to different cells and verify the cursor follows accurately to each one.

Screenshots or screencast

Before After
Screen.Recording.2026-04-15.at.7.18.34.PM.mov
Screen.Recording.2026-04-15.at.7.08.32.PM.mov

Use of AI Tools

Drafted with Gemini assistance and reviewed it before submission

@github-actions github-actions Bot added [Package] Core data /packages/core-data [Package] Editor /packages/editor [Package] Block library /packages/block-library labels Apr 13, 2026
@karthikeya-io karthikeya-io marked this pull request as ready for review April 15, 2026 13:58
@github-actions
Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: karthikeya-io <karthikeya01@git.wordpress.org>
Co-authored-by: alecgeatches <alecgeatches@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@maxschmeling maxschmeling added [Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Type] Bug An existing feature does not function as intended labels May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Feature] Real-time Collaboration Phase 3 of the Gutenberg roadmap around real-time collaboration [Package] Block library /packages/block-library [Package] Core data /packages/core-data [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RTC: Collaborator cursors don't render in table cells

2 participants