You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test(shared-notes): wait for the cursor to leave a diagram before typing - #26435
Makes the BlockNote math and diagram tests wait for a click to reach the editor before they type. It affects two clicks in sharednotes/blocknote/math-diagram.ts: the one on "Notes" in Diagrams stay light cards in dark mode, and the one on the slot in the insertFromSlashMenu helper. Test change only, 3 lines.
Why
Diagrams stay light cards in dark mode failed both attempts in the CI run of #26432, which does not touch shared notes. The editor held Notes with nothing typed after it, then Notesore the switch on the retry, where the test expects Notes before the switch. Since the test landed with #26221 on 2026-11-03 it has failed 12 attempts in 9 CI runs, both attempts in 3 of them.
After Escape, a diagram or block equation keeps the cursor with its source popup closed. While the cursor sits in such a block, SourceBlockWithPreviewExtension in @blocknote/core drops every printable key, and Backspace or Delete remove the block. On a plain click ProseMirror lets the browser move the caret and learns of it only from the asynchronous selectionchange event. The test pressed End and typed right after clicking "Notes", so its keys overtook that event and were dropped while ProseMirror still had the cursor in the diagram. Whatever came after the event landed at the end of "Notes". The 1.5 s pause before the click does not help, because the late event belongs to the click itself. Nobody types within milliseconds of a click, so this is the test's race and not a client bug.
insertFromSlashMenu has the same race when it clicks "diagram slot" right after closing the block equation. There the dropped key is Backspace, and the equation is deleted: Equations and diagrams render for every participant in run 42115106453, and Markdown export keeps equations and diagrams in run 41897184851.
After both clicks the test now waits until no diagram or equation is marked selected (ProseMirror-selectednode). That clears once the editor has taken the click, about 30 ms after it in the replay below. The second click on "Notes", before Control+Z, needs no wait, because BlockNote does not drop Ctrl shortcuts.
How was it tested?
Replayed the test's clicks and keys against the client built from ed6ce71b06 (BlockNote 0.56, as on this branch's base) and read the editor afterwards:
Case
Before
This PR
Click "Notes" after closing the diagram, then type
0 of 8: Notes, as in the first CI attempt
8 of 8
Click "diagram slot" after closing the block equation
0 of 5: equation deleted
5 of 5
Editor takes the click on "Notes" late
0 of 3 (after the 4th key): Notesore the switch, as in the CI retry
3 of 3 (after 500 ms)
The replay does not run the spec itself; the CI run of this PR does. eslint and prettier pass on both files, and so does the Playwright project's typecheck.
Not in this PR
TXT export keeps formulas with <, > and & flakes on a different race, which #26410 fixes. The two PRs change different lines of math-diagram.ts and merge cleanly in either order.
"Diagrams stay light cards in dark mode" failed both attempts in the CI
run of an unrelated PR (run 42127401054). The editor held "Notes" with
nothing typed after it, then "Notesore the switch" on the retry, where
the test expects "Notes before the switch". The test has failed 12
attempts in 9 CI runs since it landed on 2026-11-03.
After Escape, a diagram or block equation keeps the cursor with its
source popup closed. While the cursor sits in such a block, BlockNote's
SourceBlockWithPreviewExtension (@blocknote/core) drops every printable
key, and Backspace or Delete remove the block. On a plain click
ProseMirror lets the browser move the caret and learns of it only from
the asynchronous selectionchange event. The test pressed End and typed
right after clicking "Notes", so its keys overtook that event and were
dropped while ProseMirror still had the cursor in the diagram. Whatever
came after the event landed at the end of "Notes". The 1.5 s pause
before the click does not help, because the late event belongs to the
click itself. Nobody types within milliseconds of a click, so this is
the test's race and not a client bug.
insertFromSlashMenu has the same race when it clicks "diagram slot"
right after closing the block equation. There the dropped key is
Backspace, and the equation is deleted ("Equations and diagrams render
for every participant" in run 42115106453, "Markdown export keeps
equations and diagrams" in run 41897184851).
After both clicks the test now waits until no diagram or equation is
marked selected (ProseMirror-selectednode), which clears once the
editor has taken the click. The second click on "Notes", before
Control+Z, needs no wait, because BlockNote does not drop Ctrl
shortcuts.
Replaying the test's clicks and keys against the client built from
ed6ce71 (BlockNote 0.56, as on this base): the click on "Notes" left
0 of 8 runs correct before and 8 of 8 with the wait, and the click on
"diagram slot" kept the equation in 0 of 5 runs before and 5 of 5 with
the wait. Making the editor take the click only after the fourth key
reproduces the retry's "Notesore the switch" in 3 of 3 runs.
The changes add a selector for a selected BlockNote preview and check that no such preview is visible after clicking a block in the slash-menu helper and dark-mode test.
No concrete merge-blocking regression is established. The added waits address editor timing; whether they eliminate every reported race remains unverified.
Pre-merge checks: 5
Check name
Status
Explanation
Title check
The title describes the wait for the editor selection to leave a diagram before typing.
Description check
The description explains the selection wait added to the BlockNote tests and its purpose.
Docstring Coverage
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Unverified finding
We couldn't verify this from the code. It is shown for review, not as a verified issue.
A zero selected-preview count does not establish that the clicked block has received the editor selection. The same check is used in the dark-mode test.
The assertion can pass immediately, allowing Backspace to delete the previously selected equation or text to be typed at the wrong location.
This can occur when: After Escape, the click's selection update is pending while no selected-preview class is currently present in the DOM.
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 36d602fe-35de-485c-a1fd-b21d0a83b96b
Commits
Reviewing files that changed from the base of the PR and between 28d54de and b406054.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
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
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 does this PR do?
Makes the BlockNote math and diagram tests wait for a click to reach the editor before they type. It affects two clicks in
sharednotes/blocknote/math-diagram.ts: the one on "Notes" inDiagrams stay light cards in dark mode, and the one on the slot in theinsertFromSlashMenuhelper. Test change only, 3 lines.Why
Diagrams stay light cards in dark modefailed both attempts in the CI run of #26432, which does not touch shared notes. The editor heldNoteswith nothing typed after it, thenNotesore the switchon the retry, where the test expectsNotes before the switch. Since the test landed with #26221 on 2026-11-03 it has failed 12 attempts in 9 CI runs, both attempts in 3 of them.After Escape, a diagram or block equation keeps the cursor with its source popup closed. While the cursor sits in such a block,
SourceBlockWithPreviewExtensionin@blocknote/coredrops every printable key, and Backspace or Delete remove the block. On a plain click ProseMirror lets the browser move the caret and learns of it only from the asynchronousselectionchangeevent. The test pressed End and typed right after clicking "Notes", so its keys overtook that event and were dropped while ProseMirror still had the cursor in the diagram. Whatever came after the event landed at the end of "Notes". The 1.5 s pause before the click does not help, because the late event belongs to the click itself. Nobody types within milliseconds of a click, so this is the test's race and not a client bug.insertFromSlashMenuhas the same race when it clicks "diagram slot" right after closing the block equation. There the dropped key is Backspace, and the equation is deleted:Equations and diagrams render for every participantin run 42115106453, andMarkdown export keeps equations and diagramsin run 41897184851.After both clicks the test now waits until no diagram or equation is marked selected (
ProseMirror-selectednode). That clears once the editor has taken the click, about 30 ms after it in the replay below. The second click on "Notes", before Control+Z, needs no wait, because BlockNote does not drop Ctrl shortcuts.How was it tested?
Replayed the test's clicks and keys against the client built from
ed6ce71b06(BlockNote 0.56, as on this branch's base) and read the editor afterwards:Notes, as in the first CI attemptNotesore the switch, as in the CI retryThe replay does not run the spec itself; the CI run of this PR does. eslint and prettier pass on both files, and so does the Playwright project's typecheck.
Not in this PR
TXT export keeps formulas with <, > and &flakes on a different race, which #26410 fixes. The two PRs change different lines ofmath-diagram.tsand merge cleanly in either order.Closes Issue(s)
None.