Skip to content

RTC: Preserve multi-block selection overlay when an endpoint is deleted. - #82168

Open
dilipom13 wants to merge 3 commits into
WordPress:trunkfrom
dilipom13:fix/79867-rtc-multi-block-selection-overlay
Open

dilipom13 wants to merge 3 commits into
WordPress:trunkfrom
dilipom13:fix/79867-rtc-multi-block-selection-overlay

Conversation

@dilipom13

Copy link
Copy Markdown
Contributor

Fixes #79867

What?

When a collaborator deletes the first or last block of a multi-block selection, the remaining selection overlay and avatar stay visible for the surviving blocks instead of disappearing entirely.

Why?

getOrderedBlockRange() returned null when either selection endpoint was removed from the DOM, which caused both the selection rects and block highlights to clear for the whole selection.

How?

  • Add getOrderedBlockRangeWithFallback() to reconstruct the remaining block range from the last successfully rendered range when one endpoint is deleted.
  • Cache the last rendered range per collaborator in use-render-cursors and use-block-highlighting.
  • Pass the cached range through computeSelectionVisual() for multi-block selections.
  • Add unit tests for the fallback behavior.

This is a rendering-layer fix. Updating stale Yjs RelativePosition anchors after endpoint deletion remains a follow-up.

Testing Instructions

Requires two browser sessions with real-time collaboration enabled.

  1. Open the same post in two sessions (User A and User B).
  2. User A selects multiple blocks (Ctrl+A or drag selection).
  3. User B deletes the first or last block in that selection.
  4. Confirm User B still sees User A's overlay on the remaining blocks (not cleared entirely).
  5. Confirm deleting a middle block still behaves as before.

Unit tests:
npm run test:unit -- packages/editor/src/components/collaborators-overlay/test/cursor-dom-utils.ts

When a collaborator deletes the first or last block of a multi-block selection, reconstruct the remaining overlay range from the last successfully rendered range instead of clearing the entire highlight.

Fixes WordPress#79867.

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Aug 28, 2026
@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: dilipom13 <dilip2615@git.wordpress.org>
Co-authored-by: giteshsarvaiya <giteshsarvaiya@git.wordpress.org>

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Editor /packages/editor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Collaborator selection awareness overlay disappears entirely when the first or last block of a multi-block selection is deleted

1 participant