Skip to content

Flaky: Tiptap composer 'keeps text a mouse drag selects still' (19 vs 21) #1277

Backlog

Description

@scuttletoby

The upstream browser test ComposerPromptEditorTiptap.input.browser.test.tsx > Markdown markers around styled text > keeps text a mouse drag selects still, and shows markers for a click on release failed once on a pull request that does not touch this code (PR #1242, head eff9c34, Fork tests run 46218641453, job Test Web 3). The rerun passed.

 FAIL   browser (chromium)  src/components/ComposerPromptEditorTiptap.input.browser.test.tsx > Markdown markers around styled text > keeps text a mouse drag selects still, and shows markers for a click on release
AssertionError: expected 21 to be 19 // Object.is equality
- Expected
+ Received
- 19
+ 21
 ❯ src/components/ComposerPromptEditorTiptap.input.browser.test.tsx:1297:66
    1295|     for (const pos of [end - 2, "start bold wo".length + 1, "start bo"…
    1296|       await mouse("mouseMoved", point(pos));
    1297|       await vi.waitFor(() => expect(editor.state.selection.head).toBe(…

The test took 1621 ms: after the first mouseMoved the selection head stayed at the press point (21) for the whole 1 s wait, so the drag never extended the selection.

Test file is upstream code (added by upstream pingdotgg#44761). Root cause and fix: to follow on this issue.

Activity

  1. scuttletoby commented on Nov 29, 2026

    @scuttletoby
    OwnerAuthor

    Progress note (no fix yet: the local repro has not run yet, the machine had no room for it).

    What is known so far:

    • The test is upstream code (upstream fix(web): drag-selecting across styled text no longer jumps the composer pingdotgg/t3code#44761). Any change to it is an upstream-file change, so it needs a seam announcement under the fork's seam rules (two PRs), or an upstream fix.
    • The failing wait is the first step of the drag: after one mouseMoved the head stayed at the press point (21) for the whole 1 s wait. So that one synthetic move either never extended the native selection, or something collapsed it afterwards. The test sends only one move per step, so nothing extends the selection again.
    • Candidates to check with an instrumented repro (CPU-throttled, repeated):
      1. ProseMirror's focus handler: 20 ms after the first focus it calls selectionToDOM if domObserver.currentSelection differs from the DOM selection. The press is the editor's first focus (mountEditor does not focus it). If that timer runs after the move but before the selectionchange read, ProseMirror rewrites the DOM selection to its state (collapsed at 21) and Chrome does not re-extend until the next move. Its Chrome drag guard (delaySelUpdate) only skips this when currentSelection already has an anchor, and it has none before the first read.
      2. A re-render or decoration redraw between the press and the move that replaces the text node under the native drag anchor.
    • If (1) is confirmed, the fix is in the test: wait for the press to be fully taken (editor focused and ProseMirror's selection read in sync with the DOM) before the first move, not a longer sleep.

    The probe test is in the local clone (not pushed). It still needs a run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions