Opened 3 weeks ago
Closed 13 days ago
#65008 closed defect (bug) (fixed)
Block Hooks / RTC: Auto-inserted blocks duplicated on page refresh or collaborator join
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | Editor | Keywords: | has-patch dev-reviewed |
| Focuses: | Cc: |
Description
As reported here by @ingeniumed, with some edits by myself
When real-time collaboration is activated, if a post contains blocks auto-inserted by the Block Hooks API, joining a real-time collaboration session (via page refresh or a second collaborator opening the post) causes the hooked blocks to be duplicated in the editor. The duplication compounds with each new session join, and each additional collaborator or refresh adds another copy of every hooked block.
Step-by-step reproduction instructions
- Enable real-time collaboration (in Settings > Writing).
- Create a new post and add a core/heading block and a core/paragraph block.
- Publish or save the post, then close it.
- Activate the Gutenberg Block Hooks plugin from `packages/e2e-test/plugins` (or any plugin that registers blocks via the Block Hooks API).
- Reopen the post. The Block Hooks API auto-inserts its blocks (in the after and last_child positions).
- Without saving, reload the post. Observe that the auto-inserted paragraph at the end of the post has been duplicated. Notice that every subsequent reload adds another copy.
Alternative to item 5: Open the same post in a second browser window or tab to simulate a second collaborator joining the RTC session.
Change History (7)
This ticket was mentioned in PR #11410 on WordPress/wordpress-develop by @Bernhard Reiter.
3 weeks ago
#2
- Keywords has-patch added
#4
@
13 days ago
- Keywords dev-feedback added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for the backport to 7.0.
(It meets the criteria: Fixes a bug that was introduced during the 7.0 cycle.)
@Bernhard Reiter commented on PR #11410:
13 days ago
#5
Re-opening to rebase on top of 7.0 branch, to run CI there.
_Proof of concept, needs polish._
Fixes https://github.com/WordPress/gutenberg/issues/76176.
See https://github.com/WordPress/gutenberg/pull/76895#issuecomment-4162625780 and https://github.com/WordPress/gutenberg/pull/76895#issuecomment-4163602210 for an explanation.
More details to follow
Trac ticket: https://core.trac.wordpress.org/ticket/65008
## Testing Instructions
_tl;dr:_ Verify that https://github.com/WordPress/gutenberg/issues/76176 is fixed.
## TODO
This needs more work, mostly in terms of performance: It adds another full traversal of a given post's block tree, which we should be able to avoid by more cleverly extracting information that's readily available from an earlier traversal, but it will require rethinking some interfaces.
I also need to double-check if it has any other unwanted side effects (unit test coverage should help with that).
## Use of AI Tools
None