Repository navigation
Suggest mode: Reject type-over overlapping a suggestion marker - #80229
Open
i-am-chitti wants to merge 1 commit into
Open
i-am-chitti wants to merge 1 commit into
i-am-chitti wants to merge 1 commit into
Conversation
|
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
adamsilverstein
self-requested a review
July 15, 2026 04:24
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
In Suggesting mode, typing over a selection that overlaps an existing inline suggestion marker now cleanly rejects the keystroke (with a snackbar explaining why) instead of falling through to native editing, which corrupted the content.
Part of #73411. Fixes #79799.
Why?
The addition/deletion keyboards intentionally decline to build a suggestion when the current selection overlaps an existing marker (wrapping the range in a
delwould re-attribute part of that marker to a new id). The problem was how the addition keyboard declined: it returned without cancelling the event, so the browser edited a DOM that still contained the<mark class="wp-suggestion">. That native surgery corrupted the content:<mark>segments, andThis is the pre-existing behaviour documented in #79799 (not a regression from the
readEventRangeDOM-caret work in #79714 / #79752).How?
suggestion-addition-keyboard.js:insertTextnow returns a tri-state —INSERT_HANDLED(wrote a suggestion),INSERT_REJECTED(deliberately declined but must still cancel native editing),INSERT_DEFERRED(no valid inline anchor — let it fall through). TheonBeforeInput/onPastehandlerspreventDefaultonHANDLEDandREJECTED, and only fall through forDEFERRED. The type-over-overlap guard returnsREJECTED, so the browser never touches the marker DOM.Why the deletion/cut guards are left unchanged
They share the same structural shape, but their fall-through is already captured cleanly as a whole-attribute suggestion (the reconciler + store interceptor), pinned by the existing e2e test "seam: a delete straddling an existing marker never corrupts it". Rejecting them would remove that working behaviour, so this PR scopes to the addition type-over that actually corrupts.
Testing Instructions
Hello worldand switch the editor mode to Suggesting.worldand pressCtrl/Cmd+B—worldgets wrapped in a format suggestion marker.worldstill selected (do not collapse the caret), typemore.Expected: nothing is inserted, the paragraph still reads
Hello world, theworldmarker stays a single intact<mark>(no dropped space, no fragmented markers, block not emptied), and a snackbar explains why the keystroke did nothing.Automated:
test/e2e/specs/editor/various/suggestion-mode-overlay-retirement.spec.jsadds a regression test ("type-over of a selection overlapping a marker is rejected, not corrupted"). Whole spec passes locally (9/9), including the delete-straddle test that proves no regression.Screenshots or screencast
Before -

After -

Usage of AI
Claude Code - Opus 4.8