Repository navigation
fix(markdown-viewer): wait for ProseMirror's post-focus selection sync in the WebKit keyboard selection proof - #10391
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
…c before the keyboard selection proof
waleedlatif1
force-pushed
the
fix/markdown-webkit-keyboard-selection
branch
from
November 25, 2026 01:03
e775f3c to
838f57b
Compare
waleedlatif1
marked this pull request as ready for review
November 25, 2026 01:03
Collaborator
Author
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Contributor
[Low impact] This test-only change appears safe to merge. SummaryAdds a focus-linked wait before the Markdown editor’s keyboard-selection check.
The end-to-end suite was not run during this review. Reviews (1) · Last reviewed commit: "fix(markdown-viewer): wait for ProseMirr..." · Reviewed by Greptile |
This branch was previously 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.
Summary
Fixes the WebKit flake in the markdown-viewer HTTP e2e ("edit and reload an off-screen cell on a narrow screen":
Keyboard selection did not select text ... anchorOffset 1, focusOffset 1).Root cause. prosemirror-view's
focushandler schedules asetTimeout(…, 20)that writes ProseMirror's state selection back to the DOM if the DOM selection differs from the one it last observed. The test clicks "bold" (which focuses the editor) and pressesArrowLeft/Shift+ArrowRightwithin a few milliseconds. In WebKit,selectionchangeis dispatched as a separate task after the key's native selection change, so the 20 ms timer can run in between: the DOM already holds the extended selection, ProseMirror's state does not yet, and the timer collapses the DOM back to the stale caret. No transaction is involved.Evidence from CI traces on this branch (temporary instrumentation, since removed):
keydown Shift+ArrowRight→selectionchange dom=bold:1/bold:1, with no ProseMirror transaction in between.ArrowLeftinstead:Selection.collapse(bold,2)called from ProseMirror'ssetSelection←selectionToDOM← an anonymous timer callback, 26–29 ms after the editor'sfocusevent. When it hitsArrowLeftthe test still passes (it then selects "l" rather than "o"); when it hitsShift+ArrowRightit fails.This is a test race, not a product bug: a person cannot press a key within 20 ms of clicking.
Fix. Before the click, the test arms a same-delay (20 ms) timer from a focus listener registered after ProseMirror's (or immediately, if the editor already has focus). Timers with equal delays fire in the order they were set, so when that flag flips, ProseMirror's post-focus sync has already run. The test waits on the flag before pressing keys. There are no sleeps, retries, or longer timeouts, and the existing diagnostic message stays.
Type of Change
Testing
checks / e2e (markdown-viewer)with the traces and loops described above (experiment commits were dropped from the branch).checks / e2e (markdown-viewer)must pass on the final commit.Checklist