Skip to content

fix(TabList): a press measures the selected tab in the next frame, not inside the press - #8856

Merged
cixzhang merged 1 commit into
mainfrom
fix/tablist-press-skips-reveal
Oct 31, 2026
Merged

cixzhang merged 1 commit into
mainfrom
fix/tablist-press-skips-reveal

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

User impact

On a phone, pressing a tab in a scrolling TabList feels slow when the page has a heavy panel. Every selection change measured the strip (getBoundingClientRect twice, plus getComputedStyle) in an effect that React runs inside the press. Those were the first layout reads after the selection's commit, so the press paid for the whole new selection's style and layout before it could paint. The issue measures 65–80 ms at a 6× CPU throttle.

Problem and solution fit

The reveal exists for selection that moves without the user acting on the strip: on mount, or when the host sets value. A press or an arrow focuses the tab first, and TabList's focus handler already reveals the focused tab. Now, when the newly selected tab is the one whose focus revealed it and still holds focus, the selection effect measures it in the next animation frame instead. That frame has to lay the selection out anyway, so the read adds no layout of its own. It still runs because the selected weight can widen the tab. Mount and host-set changes keep the immediate reveal, so nothing flashes.

Expected behavior and authority

  • component:TabList, "Overflowing strip": selected-tab reveal stays correct. The pressed tab still ends fully inside the strip.
  • The source comment above the effect states its scope: selection that moves without focus.
  • No record change. Layout, roles, selection and overflow behavior are unchanged.

Evidence

  • New test: focusing a partly hidden tab reveals it. The press itself then reads no strip geometry, and the next frame reveals the now-wider selected tab whole. It fails before the fix, because the strip is read inside the press.
  • The existing reveal tests pass unchanged: mount, host-set value without focus, already in view, overflow change. TabList suites pass 98/98.

Closes #8846.

@vercel

vercel Bot commented Oct 28, 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 Oct 28, 2026 9:21pm UTC

Request Review

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

astracat-bot Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 29, 2026, 12:16 AM UTC

@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.

Recommending approval: a pressed or keyboard-activated tab still ends fully in view, mount and host-set selections still reveal immediately, and the new test fails without the fix. Before merging, consider the Changeset's wording. In the issue's own reproduction the click handler gets about 15 ms shorter, but the next paint lands at the same time because the same layout now runs at the start of the next frame, and Safari, which does not focus a button on click or tap, would keep the old in-press path. The code comment's reason for the next-frame pass (the selected weight widening the tab) also does not hold for default tabs, whose label already reserves the bold width.

[Automated review]

// A press or an arrow focused this tab first, and focusing it revealed
// it. Measuring now would force the new selection's style and layout
// inside the press, before it can paint. The next frame lays them out
// anyway, so finish there: the selected weight can still widen the tab.

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.

For a default Tab the selected weight does not change the width: the hidden semibold labelSizer in Tab.tsx already reserves the bold width, and in Chromium the pressed Integrations tab in the Overflow story is 109 px wide both before and after selection. The next-frame pass is still a sensible guard, since a theme or endContent can change a tab's width on selection, so consider naming that as the reason.

'@astryxdesign/core': patch
---

[fix] TabList: pressing or arrowing to a tab in a scrolling strip no longer measures the strip inside the press. Focusing the tab already scrolls it into view, so the check that keeps the selected tab whole now runs in the next frame instead of forcing the new selection's style and layout before the press can paint.

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.

In the issue's reproduction (four tabs over 3,000 rows), this makes the click handler about 15 ms shorter (median 134 to 119 ms in Chromium), but the next paint lands at the same time (148 ms median on both), because the same layout now runs at the start of the next frame. Consider describing the fix as moving the measurement out of the press rather than letting the press paint sooner. Safari, which does not focus a button on click or tap, would also keep the old path.

@cixzhang cixzhang closed this Oct 30, 2026
@cixzhang cixzhang reopened this Oct 30, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/Tab 10.5KB 10.5KB 0B 4.1KB 4.1KB 0B
core/TabList 40.6KB 40.7KB +73B 7.3KB 7.3KB 0B
core/TabMenu 56.7KB 56.7KB 0B 10.2KB 10.2KB 0B

Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included.

Bundle Size Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 35.4KB 35.4KB 0B

Accessibility Audit

Status: The accessibility audit did not run on this pull request. It runs after merges to main and before each release; pull requests that touch components run it with the ci:heavy-lanes label.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@cixzhang
cixzhang merged commit 09382da into main Oct 31, 2026
94 of 99 checks passed
cixzhang added a commit to vjeux/astryx that referenced this pull request Oct 31, 2026
@github-actions
github-actions Bot deleted the fix/tablist-press-skips-reveal branch October 31, 2026 06:09

This branch was successfully deployed

1 active deployment
Preview — 32892a16 Deployed Oct 28, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

[Bug] TabList: changing the selected tab measures the strip in an effect and forces layout inside the press

1 participant