Skip to content

test(Tokenizer): the group-scroll spec waits for the story's play function - #12017

Merged
cixzhang merged 6 commits into
mainfrom
fix/tokenizer-strip-reveal-webkit
Nov 19, 2026
Merged

cixzhang merged 6 commits into
mainfrom
fix/tokenizer-strip-reveal-webkit

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Test fix: the grouped-Tokenizer scroll browser spec waits for the story's play function before a case starts.

Maintainer impact

TokenizerGroupScroll.a11y.browser.spec.ts failed in WebKit most runs. On main, the remove-button reveal case passed 2 of 10 and the LTR fades case 9 of 10. The product works; the test raced its own story.

Cause

The InputGroup overflow story's play function scrolls the token strip to its end and then back to 0 ("leave the row at rest"). The spec's mount() waited for a visible token and for fonts, but not for play. In WebKit, play's two scrolls landed 30–100 ms into a case's Shift+Tab walk and reset the strip under a focused token. An instrumented device-farm run showed every product scroll landing correctly, and then the story resetting it.

Change

  • mount() now waits until Storybook's story render reaches finished, play function included, as the CodeBlock and AppShell browser specs already do. This Storybook also rests at finished after a play function throws, so a throwing play isn't reported here; the next case fails on its own assertions.
  • No product code changes. The case assertions are unchanged; nothing is relaxed.
  • An earlier head of this PR also changed Tokenizer.tsx to set the strip's scroll itself. The farm run below shows that change isn't needed, so it's reverted; the net diff is the spec file only.

Evidence

Device farm, TokenizerGroupScroll.a11y.browser.spec.ts, WebKit, 10 serial runs, --retries 0, SHA-stamped Storybooks:

Build Whole file Remove-button reveal Fades, LTR Fades, RTL
main, plain spec 51/60 2/10 9/10 10/10
main + this spec change only 60/60 10/10 10/10 10/10
with the earlier product change too 60/60 10/10 10/10 10/10

Chromium ×3: 18 of 18. The spec diff in this head is identical to the "main + this spec change only" build.

Scope

Test-only, so no changeset.

Owner and land path

  • Owner: Astryx maintainers, fix-loop lane 1.
  • Land path: code review, CI, merge.

Overlap checked: #11526, #11418, #9030, #8199, #4329 (they change Tokenizer or InputGroup for other behavior; this PR now changes only the group-scroll browser spec)

…ed token

Keyboard focus in a grouped Tokenizer's strip called scrollIntoView on the
focused item. WebKit often dropped that request, and its own focus scroll,
so the strip stayed at its start with the focused token wholly outside it
(8 of 10 runs of the group-scroll browser spec). The strip now measures the
item against its scroll padding (the fade width) and sets scrollLeft by the
least distance that brings the item inside, the same result as before in
Chromium.

The unit case gives the strip and the token boxes and checks the scroll
distance; it fails before this change.
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 16, 2026 10:15am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 6:23 AM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 605b4f1

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 2387055

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Tokenizer · Storybook 104.3 kB (0) · 20.3 kB CSS (0) 2,640 (0) ✓ · ✓ · ✓

Package size: no published package changed; no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.

Accessibility: 1 violation(s)

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Tokenizer - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/31 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: the new reveal must keep a wide token's focused remove button in view, and the new unit case must stop failing the test run.

  • In a left-to-right layout, Shift+Tab onto the remove button of a token wider than the strip's clear part now scrolls the token's left edge into view and leaves the focused button outside the strip, where main kept it visible (Tokenizer.tsx:985-986); when the token cannot fit, reveal the focused control instead, add a wide-token test, and limit the changeset's "fully in view" to tokens that fit.
  • The new unit case's getComputedStyle stub spreads a CSSStyleDeclaration, which drops writingMode, so the strip's next measure throws and Vitest exits 1 although every test passes (Tokenizer.test.tsx:3260-3264); return a Proxy that answers only the two scroll-padding keys, and unstub in finally.
  • scrollClearOfFades reimplements TabList's revealStop (TabList.tsx:479-507), and the two already disagree on items wider than the clear part; move the reveal into one shared helper that both components call.

Approval also needs the real-WebKit result for the remove-button reveal at this head that the description promises, because the unit case checks only arithmetic against stubbed boxes.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim, changeset: in Safari the strip scrolls a focused token fully into view, clear of the fades. False for a token wider than the clear part, whose focused button ends outside the strip (Tokenizer.tsx:985-986). The Safari part is unverified, because the real-WebKit runs are pending.
  • Claim: Safari keyboard users now see each focused token fully, as in Chromium. False for wide tokens, which now regress in Chromium too (base keeps the button at 186-202 px, head puts it at 339-355 px against a strip ending at 233 px).
  • Claim: pointer users are unchanged. Verified: the :focus-visible guard is unchanged (Tokenizer.tsx:953-958).
  • Claim: no API change. Verified: only non-exported functions change.
  • Claim: WebKit dropped the scroll in 8 of 10 runs. Not verifiable here, because WebKit could not run in this review.
  • Claim: the strip measures the item against its box minus scroll padding and scrolls the least distance, replacing scrollIntoView. Verified (Tokenizer.tsx:976-997).
  • Claim: it is the same under right-to-left. True for tokens that fit. False for wide tokens: right-to-left keeps the focused button visible, left-to-right does not.
  • Claim: an item wider than the clear part keeps its left edge in view. Verified as written; it is the first finding.
  • Claim: keyboard focus only. Verified.
  • Claim: the scrollable-container spec and the group-scroll browser spec state the reveal. The browser spec asserts it (TokenizerGroupScroll.a11y.browser.spec.ts:257-302). The clause that states it is the Tokenizer component record's FR30; the custom-scrollbar clause cited does not.
  • Claim: the unit case fails on main and passes here. Verified: "expected +0 to be 114" on the base.
  • Claim: the Tokenizer and InputGroup suites pass 318 of 318, and tsc and eslint are clean. All 318 tests pass and tsc and eslint report no errors, but the run exits 1 on an unhandled TypeError from the new case (the base exits 0).
  • Claim: the real-WebKit 10-run comparison is to be added. Pending.
  • Claim: five overlapping pull requests do not touch the strip's focus reveal. Verified: none of their patches touches it.
  • Claim, commit message: Chromium gives the same result as before. False for wide tokens.
  • File .changeset/tokenizer-strip-reveal-webkit.md: "fully in view" overstates the result for wide tokens (first finding).
  • File packages/core/src/Tokenizer/Tokenizer.tsx: the first and third findings; the new JSDoc's first sentence restates the function (non-blocking).
  • File packages/core/src/Tokenizer/Tokenizer.test.tsx: the second finding.

Automated review (maintainer link)

…ction

The InputGroup overflow story's play function scrolls the strip to its end
and back to rest. The spec's mount waited for a visible token and fonts but
not for play, so in WebKit those scrolls landed 30-100 ms into a case's
Shift+Tab walk and reset the strip under a focused token. mount now waits
for Storybook's story render to reach its completed phase, and fails if the
play function errored. The product assertions are unchanged.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec ff22fe1

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: the reveal must keep a wide token's focused remove button in view, the browser spec's new wait must be able to finish, and the new unit case must stop failing the test run.

  • In a left-to-right layout, Shift+Tab onto the remove button of a token wider than the strip's clear part scrolls the token's left edge into view and leaves the focused button outside the strip, where main kept it visible (Tokenizer.tsx:985-992); when the token cannot fit, reveal the focused control instead, add a wide-token test, and limit the release note's "fully in view" to tokens that fit.
  • The group-scroll browser spec's mount() waits for the story render's completed or errored phase, but this Storybook passes through completed within one task on its way to finished, so all six cases time out at 60 s in Chromium (TokenizerGroupScroll.a11y.browser.spec.ts:57-66); wait for finished, as the shared openStory helper does, and detect a failed play function separately.
  • The new unit case's getComputedStyle stub spreads a CSSStyleDeclaration, which drops writingMode, so the strip's next measure throws and Vitest exits 1 although every test passes (Tokenizer.test.tsx:3260-3264); return a Proxy that answers only the two scroll-padding keys, and unstub in finally.
  • scrollClearOfFades reimplements TabList's revealStop (TabList.tsx:478-509), and the two already disagree on items wider than the clear part; move the reveal into one shared helper that both components call.

Approval also needs the real-WebKit result for the remove-button reveal at this head, which the spec can give once its wait is fixed.

Claims and files checked

Review mode: incremental; reason: none

  • Claim, release note: in Safari the strip now scrolls a token whose remove button takes keyboard focus fully into view, clear of the fades. False for tokens wider than the clear part (Tokenizer.tsx:985-992); the Safari part is unverified, since no WebKit result exists for this head.
  • Claim: Safari keyboard users now see each focused token fully, as in Chromium. False for wide tokens, which regress in Chromium too (button at 339-355 px against a strip ending at 233 px; main kept it at 186-202 px).
  • Claim: pointer users are unchanged. Verified: the :focus-visible guard is unchanged (Tokenizer.tsx:953-958).
  • Claim: no API change. Verified: the built API surface of Core and the themes is identical on base and head.
  • Claim: WebKit kept the strip at 0 in 8 of 10 runs and Chromium scrolled in 3 of 3. Not verifiable here, because WebKit could not run in this review.
  • Claim: the strip measures the item against its box minus scroll padding and scrolls the least distance, replacing scrollIntoView. Verified (Tokenizer.tsx:976-997).
  • Claim: the result is the same under right-to-left. True for tokens that fit; for wide tokens right-to-left keeps the focused button visible and left-to-right does not.
  • Claim: an item wider than the visible part keeps its left edge in view. Verified as written; it is the first finding.
  • Claim: keyboard focus only. Verified (Tokenizer.tsx:953-958).
  • Claim: setting scrollLeft follows the strip's computed scroll-behavior, which the strip leaves unset, so the jump stays instant. Verified: the track sets no scroll-behavior (Tokenizer.tsx:560-585).
  • Claim: the scrollable-area record's keyboard and custom-scrollbar clauses state the reveal clear of the fades. Partly false: they cover keyboard reach and scrollbar presentation; the Tokenizer record's grouped-mode clause states the reveal, and the browser spec asserts the fade clearance.
  • Claim: the unit case fails on main and passes here. Verified on the same test file ("expected +0 to be 114" on the base); it passes at this head.
  • Claim: the Tokenizer and InputGroup suites pass 318 of 318, with tsc and eslint clean. Every test passes, but the run exits 1 on an unhandled TypeError from the new case (the Tokenizer file alone: 176 passed, 1 error).
  • Claim: real WebKit passed 0 of 10 on main and 5 of 10 with the product change alone, and the story's play function raced the case. Not verifiable here (WebKit unavailable); the story's play function does scroll the strip to its end and back (InputGroup.stories.tsx:386, :405).
  • Claim: the spec's mount() now waits for the story render to complete and fails if play errored. False: it waits for a phase the render never rests in, so every case times out, and an errored render also ends at finished, so the error branch never fires.
  • Claim: the product assertions are unchanged. Verified: the diff touches only mount() and adds a type.
  • Claim: at this head Chromium passes 18 of 18. False: 0 of 6 Chromium cases pass, each timing out in mount(); with the wait on finished, 6 of 6 pass.
  • Claim: five overlapping pull requests do not touch the grouped strip's focus reveal. Verified: none of their patches touches it.
  • Claim, commit messages: Chromium gives the same result as before (false for wide tokens); mount waits for the completed phase and fails on a play error (false, as above).
  • File .changeset/tokenizer-strip-reveal-webkit.md: "fully in view" overstates the result for wide tokens (first finding).
  • File packages/core/src/Tokenizer/Tokenizer.tsx: first and fourth findings; the new JSDoc's first sentence restates the function (non-blocking).
  • File packages/core/src/Tokenizer/Tokenizer.test.tsx: third finding.
  • File packages/core/src/Tokenizer/__tests__/TokenizerGroupScroll.a11y.browser.spec.ts: second finding.

Automated review (maintainer link)

…nished or completed

This Storybook's render rests at "finished", not "completed", so the wait
never resolved. It now accepts either, and fails only if play errored.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec df0d6d4

… whole failure

On the device farm, main plus only the spec's wait for the story's play
function passes the WebKit group-scroll spec 10 of 10 (remove buttons and
fades). The browser's scrollIntoView was never dropped: the story's play
function reset the strip under the case. Tokenizer.tsx, its unit case and
the changeset go back to main's; only the spec change remains.
@cixzhang cixzhang changed the title fix(Tokenizer): a grouped strip scrolls a keyboard-focused token into view in WebKit test(Tokenizer): the group-scroll spec waits for the story's play function Nov 16, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec bf045af

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 16, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes requested: the spec's new wait does start each case after the story's play function, but its guard against a failed play function cannot fire, and the description says it does.

  • mount() accepts the render phases finished, completed and errored and then asserts the phase is not errored, yet this Storybook leaves a render that caught a play-function exception at finished just like a healthy one, so the assertion never fires: probed with the overflow story's play function forced to throw, mount() resolved as usual and the strip was left at the end of its scroll instead of the rest position play restores, which makes the next case fail on geometry instead of naming the story (TokenizerGroupScroll.a11y.browser.spec.ts:62-69); either detect the play exception on Storybook's addons channel, or wait for finished alone as the shared story helper and the CodeBlock, TabBar and AppShell waits do and drop the claim from the description.

Two smaller points, neither blocking: completed is unreachable in this Storybook for the same reason the error branch is, and the wait accepts any current render where the shared helper also checks the render's story id. Reverting the strip's own scroll resolves the three earlier findings on the component and its unit case, and all six cases now pass in Chromium here, three runs out of three. The WebKit result this change is about cannot be reproduced in review, so it stands on the device-farm results stated in the description. CI has not run at this head because the pull request is a draft: marking it ready for review, or adding the ci:run label, runs the accessibility specs.

Claims and files checked

Review mode: incremental; reason: none

  • Claim: the spec's mount waits for the story's play function before a case starts. Verified: the wait resolves only once the render rests, which is after play, its animation wait and its afterEach hooks.
  • Claim: it fails the case if the play function errored. False, and the blocking finding above.
  • Claim: no product code changes, and the net change is the spec file only. Verified: the one changed file at this head is the browser spec, and the component source and story match the default branch.
  • Claim: the case assertions are unchanged and nothing is relaxed. Verified: the diff adds one type and the wait inside mount.
  • Claim: Chromium passes 18 of 18. Verified here: the six cases passed three times over, with no retries.
  • Claim: the device-farm WebKit results, 10 of 10 with this spec change against 2 of 10 for the remove-button case on the default branch. Not verifiable in review: WebKit could not run here, and this repository runs the spec under WebKit only in its weekly report-only job.
  • Claim: the story's play function scrolls the strip to its end and back, which raced the case. Verified in the story's source, which scrolls to the end and resets to rest on its last line.
  • Claim: test-only, so no changeset. Verified: the repository's changeset classifier treats a path inside a tests folder as outside a package's release surface.
  • Claim: the five overlapping pull requests do not touch this spec. Verified: none of their changed files includes it.
  • Claim, commit message: the wait accepts either resting phase and fails only if play errored. The first half is verified, the second is the blocking finding.
  • File packages/core/src/Tokenizer/__tests__/TokenizerGroupScroll.a11y.browser.spec.ts: the blocking finding and the two smaller points; the rest of the file is unchanged and passes.

Automated review (maintainer link)

…waits do

This Storybook leaves a render at finished whether or not its play function
threw, so the errored check could not fire. The wait now matches the
CodeBlock and AppShell specs: it resolves when the render reaches finished.
A play function that throws is not reported here; the next case fails on
its own assertions.
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 2387055

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved: every required check has passed on this head.

mount() now waits for the story render to reach finished, which Storybook reaches after the play function in every outcome, so the play function's scroll to the end and back can no longer land inside a case. All six cases pass in this pull request's Chromium accessibility run; the WebKit result rests on the device-farm runs in the description.

Two optional points, neither blocking: the wait accepts whichever render is current where the shared openStory helper also checks the story id, and the description's "the next case fails on its own assertions" holds only for a play function that throws after its scroll to the end, while CI's story play guard reports a throwing play for both overflow stories either way.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: the spec failed in WebKit on most runs, with the remove-button reveal case passing 2 of 10 and the left-to-right fades case 9 of 10 on the default branch. Not verifiable in review: WebKit could not run here.
  • Claim: the product works and the test raced its own story. Consistent: the head changes only the spec and its cases pass; the WebKit part rests on the device-farm runs.
  • Claim: the overflow story's play function scrolls the strip to its end and then back to 0. Verified in the story source.
  • Claim: mount waited for a visible token and for fonts, but not for play. Verified in the default branch's spec.
  • Claim: in WebKit, play's two scrolls landed 30 to 100 ms into a case's Shift+Tab walk, and an instrumented device-farm run showed every product scroll landing correctly. Not verifiable in review.
  • Claim: mount now waits until the render reaches finished, play included, as the CodeBlock and AppShell browser specs already do. Verified: both specs poll the same phase.
  • Claim: the render also rests at finished after a play function throws, so a throwing play is not reported by this spec. Verified in the Storybook version the repository uses.
  • Claim: the next case then fails on its own assertions. Partly verified: true for a throw after play's scroll to the end, not for an earlier one.
  • Claim: no product code changes, the case assertions are unchanged and nothing is relaxed. Verified: the one changed file is the spec, and the diff adds only a type and the wait.
  • Claim: an earlier head's component change is reverted and the net diff is the spec file only. Verified.
  • Claim: the device-farm table, 51 of 60 for the whole file on the default branch against 60 of 60 with this spec change, with or without the earlier component change. Not verifiable in review.
  • Claim: Chromium, three runs, 18 of 18. Verified: 18 passed with no retries against a Storybook built from this head, and all six cases pass in this pull request's CI.
  • Claim: the spec diff equals the device-farm build with only the spec change. Not verifiable in review.
  • Claim: test-only, so no changeset. Verified: the release changeset check treats a spec file as not shipping.
  • Claim: the five overlapping pull requests change the component or the group for other behaviour, not this spec. Verified: none of their changed files is this spec.
  • Claim, commit messages: the final wait rests on finished as the other story waits do, and the changeset is dropped because a test-only change takes none. Verified. The revert commit's "the spec race was the whole failure" rests on the device-farm runs.
  • File packages/core/src/Tokenizer/__tests__/TokenizerGroupScroll.a11y.browser.spec.ts: the two optional points above; otherwise clear.

Automated review (maintainer link)

Comment on lines +58 to +62
await page.waitForFunction(
() =>
(window as StorybookPreviewWindow).__STORYBOOK_PREVIEW__?.currentRender
?.phase === 'finished',
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optional: this accepts whichever render is current. openStory in internal/interaction-harness/src/story.ts also checks render.id === storyId and turns off Storybook's highlight module, so openStory(page, storybook.origin, story) could replace the navigation, the fonts wait and this poll. Each mount loads a fresh page with one story, so nothing goes wrong today.

@cixzhang
cixzhang marked this pull request as ready for review November 19, 2026 06:02
@cixzhang
cixzhang merged commit ddab5b7 into main Nov 19, 2026
149 checks passed
@github-actions
github-actions Bot deleted the fix/tokenizer-strip-reveal-webkit branch November 20, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 2387055c Deployed Nov 16, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant