Repository navigation
fix(TabList): a press measures the selected tab in the next frame, not inside the press - #8856
Conversation
…t inside the press Closes #8846.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewComponent Size
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 SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
…import kept with waitFor)
User impact
On a phone, pressing a tab in a scrolling
TabListfeels slow when the page has a heavy panel. Every selection change measured the strip (getBoundingClientRecttwice, plusgetComputedStyle) 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, andTabList'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.Evidence
Closes #8846.