Skip to content

test(ios): pin #4394 root cause to stale offsetRef onMouseUp#5

Merged
ethan-james merged 1 commit into
ethan-james-fix-caret-focus-wdio-testfrom
ethan-james-musical-umbrella
Jul 8, 2026
Merged

test(ios): pin #4394 root cause to stale offsetRef onMouseUp#5
ethan-james merged 1 commit into
ethan-james-fix-caret-focus-wdio-testfrom
ethan-james-musical-umbrella

Conversation

@ethan-james

Copy link
Copy Markdown
Owner

cybersemics#4394

Root cause (confirmed)

This branch predates PR cybersemics#4371 (pressingRef absent; cybersemics#4371 is not an ancestor of HEAD). In the pre-cybersemics#4371 useEditMode.ts:

  • offsetRef.current is assigned when a cursor thought is tapped (line 178) but is never reset to null.
  • The priming tap leaves a stale non-null offset. After the cursor is cleared, the [iOS] Keyboard incorrectly opens when tapping right edge of thought cybersemics/em#4394 edge fat-tap makes iOS 18 Safari's touch-adjustment heuristic retarget the synthesized mouse cascade onto the non-cursor editable.
  • onMouseDown -> else -> e.preventDefault() blocks native focus.
  • The retargeted mouseup -> onMouseUp reads the stale offsetRef.current -> setCaretOffset -> selection.set() -> programmatic focus -> keyboard opens.

PR cybersemics#4371 deleted onMouseUp/offsetRef and moved setCaretOffset into a guarded onMouseDown, removing the vector. cybersemics#4407 sits on post-cybersemics#4371 main and only adds test files, so it passes; caretFocus.ts is byte-identical between the two branches.

Why the prior isolated H2 spec was wrong

caretFocusIsolated.ts's fixture editable had only mousedown(preventDefault) + a focus probe and no mouseup/selection, so it accidentally modeled the fixed (post-cybersemics#4371) code and correctly showed focused:false. The H2 assertion (focused:true) therefore failed, and the conclusion "iOS ignores mousedown preventDefault" only holds for the no-mouseup configuration — it missed the one variable that distinguishes buggy from fixed: the stale-offset onMouseUp selection.

Changes

Draft: pending BrowserStack CI to confirm the reproduce/control specs and the iOS 17-vs-18 assertions.

Re-model the isolated caret-focus diagnostics around the confirmed root
cause: pre-cybersemics#4371 useEditMode never resets offsetRef.current, so the
retargeted mouseup runs onMouseUp -> setCaretOffset -> selection.set and
focuses the editable despite onMouseDown preventDefaulting the native
focus. The reproduce spec adds a stale-offset mouseup selection (models
pre-cybersemics#4371) and shows focus/keyboard proceed; the control spec omits it
(models post-cybersemics#4371) and shows focus stays blocked.

Make caretFocus.ts version-aware and add a dedicated iOS 17 BrowserStack
capability so the same edge tap positively asserts the keyboard opens on
iOS 18 but stays down on iOS 17, verifying the bug is iOS-18-specific.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@ethan-james ethan-james merged commit d928e2c into ethan-james-fix-caret-focus-wdio-test Jul 8, 2026
8 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant