Skip to content

fix(demo): give focus back to the button that opened the sheet or shortcuts in Safari - #329

Merged
Moltenship merged 3 commits into
mainfrom
fix/solid-demo-webkit
Nov 26, 2026
Merged

Moltenship merged 3 commits into
mainfrom
fix/solid-demo-webkit

Conversation

@Moltenship

Copy link
Copy Markdown
Owner

Two WebKit failures in the Solid demo's checks (tools/a11y/tests/solid/demo.a11y.tsx) blocked the release gate's browsers step. They have different causes.

1. The keyboard drop, in Linux WebKit: a test artefact, not the clock

"a task picked up with Space drops onto the week as an event" failed in the release gate (runs 45722903475 and 45726058412) with "expected null not to be null".

Not the clock. In a Linux WebKit container (Playwright's image, TZ=UTC) the drop failed:

  • in 3 of 8 runs with Temporal.Now frozen at 10:30;
  • in some runs with it frozen at 23:30, 23:45 and 23:59, about as often;
  • once in 4 runs of the whole file at the real time.

When it failed, every key arrived and the drag's drop() ran, but it proposed nothing.

The cause.

  • The "Call the dentist" card sticks out 18 px below the sidebar, so card.focus() scrolls the sidebar.
  • Chromium scrolls inside focus(), as the HTML spec has it. WebKit scrolls on a later frame, about 35 ms after focus() in the probe. The sidebar's scrollTop was still 0 after a microtask and after the next animation frame.
  • The test pressed Space at once, so in the runs where Space came first, the drag started from the card's old centre, y = 795. That's below the time grid's body, which ends at 787.
  • The arrows then moved the point sideways along that line, under the hours, and the drop landed on no slot.

A person can't press Space within a frame of tabbing to the card, so the demo is fine. The test now:

  • waits for the card to show within the sidebar before it picks it up;
  • waits for the drop preview before it drops, so a lost drop fails at the step that broke.

2. The sidebar's sheet, in macOS WebKit: a demo bug, on the StyleX page too

"the sidebar's sheet" failed every time in macOS WebKit: after Escape, focus was on <body>, not on "Open sidebar".

The cause.

A Safari user who opened the sheet or the shortcuts with a click, then pressed Escape, lost their place.

The fix.

  • The Solid and StyleX top bars pass the button pressed, and the sheet and the shortcuts dialog take it as ui-sdk's finalFocus.
  • The "?" key still opens the shortcuts with the default.
  • I didn't use a ui-sdk trigger, which would add aria-expanded and aria-haspopup on two of the three pages, a difference the parity test would report.

The tests.

  • They press the buttons without focusing them (tools/a11y/tests/clicks.ts), as Safari does, so Chromium in the PR gate checks the fix too.
  • The Solid file adds a shortcuts check beside the sheet's.
  • demo-stylex.a11y.tsx checks both buttons.
  • Without the demo change, all 5 fail in Chromium and in WebKit.

Screenshots

The Solid demo on a phone in macOS WebKit, after "Open sidebar" is clicked and the sheet is closed with Escape. After the fix, the menu button keeps focus, with its ring; before, focus is on the page.

Before After
Phone, light The top bar with no focus on the menu button The top bar with a focus ring on the menu button
Phone, dark The dark top bar with no focus on the menu button The dark top bar with a focus ring on the menu button

Checks

  • Keyboard drop, Linux WebKit:
    • alone: 10 of 10;
    • alone, with the clock frozen at 23:45: 10 of 10;
    • the whole file: 10 of 10, from 00:28 to 00:36 UTC in the page's zone.
    • Before the fix, the whole file failed 1 run in 4.
  • macOS WebKit, 10 of 10 for each of these:
    • the keyboard drop;
    • both sheet tests;
    • the Solid shortcuts check;
    • the two StyleX checks.
  • vp run ready: green on 7a0d402, "ready: every PR check passed", 34/34 tasks, exit 0. Also green on 022ccc0, before the review's fixes
  • vp run browsers (macOS): green on 7a0d402, 41 files and 565 tests passed, exit 0. Also green on 022ccc0
  • CI's release-gate job, dispatched on this branch: see the comment below

Review

One round by Claude Opus 5.5 (high). No blockers.

Finding Answer
The new focus checks pass without the fix in Chromium and Linux WebKit, which focus a clicked button: only macOS WebKit tested it should-fix Fixed: the press leaves focus where it was in every engine. Without the demo change all 5 fail in Chromium too
ui-sdk already skips a final focus target that's gone, so the connected helpers add nothing nit Fixed: dropped
The comment over the openers is hard to parse nit Fixed: shortened
setTheme("light") adds nothing to the StyleX check nit Fixed: dropped

🤖 Generated with Claude Code

Moltenship and others added 3 commits November 26, 2026 04:39
… into view

The keyboard drop test focused the "Call the dentist" card and pressed Space at once. The card
sticks out 18 px below the sidebar, and WebKit scrolls a focused element into view on a later
frame, not in focus(). When Space came first, the drag started from the card's old centre,
below the time grid's hours, and the drop landed nowhere. It failed in Linux WebKit about once
in four runs of the file, at any time of day.

The test now waits for the card to show within the sidebar before picking it up, and for the
drop preview before dropping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rtcuts in Safari

WebKit, like Safari, doesn't focus a button it clicks. The Solid and StyleX pages open the
sidebar's sheet and the shortcuts dialog from state, with no dialog trigger, so on close
ui-sdk's dialog returned focus to what had it before they opened: the page. The Tailwind
page kept it, because Base UI's button focuses itself on press.

The top bars now pass the button pressed, and the sheet and the dialog take it as finalFocus.
The "?" key still opens the shortcuts with the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ari does

The new focus checks passed without the fix in Chromium and in WebKit on Linux, which focus a
clicked button, so only macOS WebKit tested it. A press now leaves focus where it was in every
engine. Also from the review: ui-sdk already skips a final focus target that's gone, so the
demos pass the opener as it is.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Moltenship

Copy link
Copy Markdown
Owner Author

Local gate on 7a0d402 (macOS):

  • vp run ready: green, "ready: every PR check passed", 34/34 tasks, exit 0.
  • vp run browsers: green, 41 files and 565 tests passed, exit 0.

Dispatched CI on this branch for the release gate: run 45731703066, https://github.com/Moltenship/time/actions/runs/45731703066 (in progress when posted).

@Moltenship

Copy link
Copy Markdown
Owner Author

Merging. On 7a0d402 the PR check (run 45731693392) is green. The dispatched release gate (run 45731703066) passed everything this PR touches in Linux WebKit: 564 of 565 tests in browsers, the keyboard drop and the sheet among them. Its one failure is react (webkit) tests/demo.a11y.tsx > demo, dark theme > event editor dialog, colour contrast measured while the dialog fades in, which failed on main before this PR (run 45726058412) and has its own fix coming.

@Moltenship
Moltenship merged commit 8127d64 into main Nov 26, 2026
5 of 6 checks passed
@Moltenship
Moltenship deleted the fix/solid-demo-webkit branch November 26, 2026 01:07
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