Skip to content

Commit 492bfc0

Browse files
Suggestions: Adopt synced reject of a pending-insert instead of re-tagging
Rejecting a pending-insert suggestion dispatches a `removeBlock` to undo the insert. When that lands on a peer client through sync, batched with the marker-clearing `updateBlockAttributes`, the removal-detection branch was treating the disappearance as a fresh user delete — re-inserting the block and tagging it pending-remove. That re-insert bounced back through sync and undid the reject on the rejecting client a moment after they clicked. Extend the apply-landing check to also recognize `pending-insert` in the previous-tick tree snapshot. The marker presence means the removal is the reject landing; adopt it.
1 parent 60a8b52 commit 492bfc0

1 file changed

Lines changed: 22 additions & 15 deletions

File tree

packages/editor/src/components/suggestion-mode/store-interceptor.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -696,24 +696,31 @@ export default function SuggestionStoreInterceptor() {
696696
const removedIds = [];
697697
for ( const clientId of tree.blocksByClientId.keys() ) {
698698
if ( ! live.has( clientId ) ) {
699-
// "Apply landing": when another client accepts a
700-
// `pending-remove` suggestion, the resulting
701-
// `removeBlock` arrives here through sync —
702-
// typically batched with the marker-clearing
703-
// `updateBlockAttributes` into a single block-
704-
// editor update, which fires this subscriber
705-
// once. The previous-tick tree snapshot still
706-
// carries the pending marker, so we can recognize
707-
// the disappearance as the apply landing rather
708-
// than a fresh user delete. Adopt the removal:
709-
// drop the snapshot entry and skip the re-insert
710-
// + re-tag path. Without this, the apply bounces
711-
// back through sync and undoes the removal on the
712-
// accepting client a moment after they clicked.
699+
// "Apply / reject landing": when another client
700+
// accepts a `pending-remove` — or rejects a
701+
// `pending-insert`, which also dispatches
702+
// `removeBlock` to undo the insert — the
703+
// resulting `removeBlock` arrives here through
704+
// sync, typically batched with the marker-
705+
// clearing `updateBlockAttributes` into a
706+
// single block-editor update, which fires
707+
// this subscriber once. The previous-tick
708+
// tree snapshot still carries the pending
709+
// marker, so we can recognize the
710+
// disappearance as the suggestion landing
711+
// rather than a fresh user delete. Adopt the
712+
// removal: drop the snapshot entry and skip
713+
// the re-insert + re-tag path. Without this,
714+
// the apply / reject bounces back through
715+
// sync and undoes the change on the accepting
716+
// client a moment after they clicked.
713717
const trackedMarker =
714718
tree.blocksByClientId.get( clientId )?.attributes
715719
?.metadata?.suggestion?.type;
716-
if ( trackedMarker === 'pending-remove' ) {
720+
if (
721+
trackedMarker === 'pending-remove' ||
722+
trackedMarker === 'pending-insert'
723+
) {
717724
snapshot.delete( clientId );
718725
continue;
719726
}

0 commit comments

Comments
 (0)