Skip to content

Commit fecb80f

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 f9cddd5 commit fecb80f

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

0 commit comments

Comments
 (0)