Skip to content

Host browser tests: choosing a mode in the menu waits for its focus to return - #99

Merged
agorischek merged 2 commits into
mainfrom
mode-menu-closed
Nov 20, 2026
Merged

agorischek merged 2 commits into
mainfrom
mode-menu-closed

Conversation

@agorischek

@agorischek agorischek commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

The flake

Failure (Nov 18–20) Jobs Branches On main
browser (packages/host/core): modes.spec.ts:188 "embedders can control the comparison mode and divider": Tour divider stays at "50%" after ArrowRight, expected "51%" (webkit-mobile ×3, chromium-mobile ×1, on #93) 4 4 1

Cause

The failures only happen on the mobile projects. At mobile widths the comparison-mode switch is folded into a menu (a Radix popover). Choosing Swipe there closes the menu, but the popover gives focus back to its button only as it unmounts, after its exit animation. Meanwhile the test had already focused the swipe divider (.focus()), and the closing menu took focus back before ArrowRight, so the key went to the menu button.

Fix

chooseMode in packages/host/core/browser/harness.ts now handles a mode chosen in the menu. It waits until no popover is playing its exit animation (settled, i.e. the menu has unmounted). Then it flushes one 0 ms timer in the page: Radix's focus scope hands focus on in a 0 ms timer started at unmount, and timers run in order. Every caller that focuses or types next keeps the focus it sets. Waiting for the button itself to take focus didn't work: on the mobile projects focus doesn't return there (an earlier push of this PR failed that way). The inline (desktop) form is unchanged.

…o return

modes.spec's "embedders can control the comparison mode and divider" failed
on the mobile projects (webkit-mobile 3 times, once on main, and
chromium-mobile): ArrowRight on the swipe divider left it at 50%. There the
mode switch is a menu. Choosing Swipe closes it, and the popover gives focus
back to its button only as it leaves, after its exit animation. The test had
focused the divider by then, and the menu took the focus back before the key.
chooseMode now returns once the menu is gone and its button has focus.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the focus-restoration waits added to menu-based mode selection.

No open issues 🎉

What changed in this PR

Updates the shared host browser-test helper to prevent a closing comparison-mode menu from stealing focus before subsequent keyboard interactions, addressing the intermittent mobile divider test failure.

Changes:

  • Detects whether the mode was selected through the menu.
  • Waits for popover exit animations to finish and focus to return to the menu button, leaving inline desktop selection unchanged.
File Description
packages/​host/​core/​browser/​harness.ts Adds and documents focus-restoration waits in chooseMode for menu-based selections.

Review effort: Balanced

…wherever focus goes

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
agorischek added a commit that referenced this pull request Nov 20, 2026
…istry's newest (#108)

* Scaffold checks: install the workspace's locked versions, not the registry's newest

check-pack.mjs (the package job) and the CLI's starter browser specs (browser
rest) npm-install a freshly scaffolded renderer, whose package.json asks for
ranges such as @playwright/test ^1.55.0. Resolved against the live registry,
that took 1.65.1, released Nov 13, whose playwright-core the registry mirror
didn't list yet: ETARGET No matching version found for playwright-core@1.65.1,
on #91, #92, #99, #101 and #103 on Nov 20. Every new release could do the same.

Both now pin the scaffold's registry dependencies to the versions this
workspace's lockfile installed (failing if a range and the installed version
disagree on the major version), so they build with what CI already tested.
npm also retries a request that fails on the network or with a 5xx five times
rather than twice; it never retries a missing version.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* check-pack: pin the scaffold in a module of its own, within check-pack's complexity

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit 67f4a55 into main Nov 20, 2026
164 checks passed
@agorischek
agorischek deleted the mode-menu-closed branch November 20, 2026 23:41
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.

2 participants