Repository navigation
feat(lab): reselecting a TabBar tab scrolls its panel to the top - #9966
Conversation
|
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.
This needs an engineering owner's decision before it can be approved, and it needs changes either way.
No current record governs Lab TabBar or its new reselect rule (choosing the selected tab again scrolls the panel named by panelId, or its first vertically scrolling element, to the top, and still calls onReselect). The Lab exemption does not apply because the diff against main also changes Core. An engineering owner, the author included, can approve that direction by commenting /approve-spec with the full head commit SHA, or name the record that must govern it first.
Blocking findings:
- Merged with current
main, thecreateMotionAnimatortocreateMotionEnginerename leavespackages/core/src/DateInput/wheelStrip.ts(lines 19 and 135) and a new call atpackages/core/src/motion/animator.test.ts:4370importing a removed export, andpackages/lab/src/index.tsconflicts, so rebase onto the current #9754 head ormain. - The diff against
mainis 6,099 authored lines from four separable pull requests with noStack:line here, so put one identicalStack: #9754 → #9699 → #9700 → #9966line in every listed description, with each head built on the one below, or land the lower pull requests first. - TabBar turns off the shared action-group tracker's press paint (
useTabBarLens.ts:607) and repaints the same tab with its owndata-tab-bar-pressedattribute (useTabBarLens.ts:80-90), so passpaintsHighlight: !isTouch || selectedIndex < 0and style the shareddata-astryx-pressattribute instead, or extend the shared tracker and say why it cannot serve. TabBar.doc.mjs(lines 46 and 118) tells builders to use a NavigationStack that no package provides, and implies the panel scrolls only at a stack's root, while TabBar scrolls on every reselect.
The reselect scroll itself works as described in the Scroll To Top story, but CI has not run on this head yet.
[Automated review]
26fb252 to
de5fe68
Compare
|
Restacked onto #9700's new head. The docs now say "return the tab's navigation stack to its root" without naming a component, and that TabBar scrolls the tab's panel to its top on every reselect. |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| lab/TabBar | 77.5 kB (+492 B) · 1.8 kB CSS (0) | — |
| lab/TabBarItem | 3.8 kB (0) · 1.8 kB CSS (0) | — |
Package size: no published package changed; no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 29 rows, core 36 rows; run pnpm api:report.
Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Generated by PR Enrichment workflow | View full report
|
/approve-spec de5fe68 |
There was a problem hiding this comment.
Changes are needed in #9754, and #9700 and #9966 wait on an engineering owner's decision.
#9754: changes requested
.changeset/core-internal-touch-entry-lab-animator.mdsays Lab's PageControl and NavigationStack read the new internal-entry names, but no package ships either component, so name only TabBar (or "Lab components") in that release note.
#9699: can be approved on its own.
#9700: waiting on an owner decision
- No current record governs Lab
TabBarandTabBarItem, and the stack also changes Core and the Storybook app, so the Lab exemption does not apply: an engineering owner approves this direction by commenting/approve-specwith the full head SHA, or names the record that must govern it, and the author may do so if they are an engineering owner.
#9966: waiting on the same decision
- No current record governs the reselect rule (choosing the selected tab again scrolls the panel
panelIdnames, or its first vertically scrolling element, to the top, and still callsonReselect), and the same/approve-speccovers it.
Whole stack: changes requested, because of the #9754 changeset. A pull request lands only when it and every pull request below it are approved, and CI has not run on this head yet.
[Automated review]
de5fe68 to
372e68f
Compare
|
/approve-spec 372e68f |
There was a problem hiding this comment.
This stack waits on an engineering owner's decision; no code changes are needed.
#9754: can be approved on its own. The internal rename and re-exports stay on Core's internal entry, and the release note now names no component the stack does not ship.
#9699: can be approved on its own. The tracker's new options are optional, and AlertDialog's path is unchanged.
#9700: waits on an engineering owner's decision.
- No current spec record governs Lab
TabBarandTabBarItem(the selection lens, press tracking and badges), so an engineering owner needs to approve them as Lab direction.
#9966: waits on an engineering owner's decision.
- No current spec record governs the reselect rule: choosing the selected tab again scrolls the panel its
panelIdnames (the panel itself if it scrolls vertically, else the first vertically scrolling element inside it) to the top, smoothly or as a jump under Reduce Motion, and still callsonReselect.
Whole stack: the cumulative change has no blocking issue. A pull request lands only when it and every pull request below it are approved.
This direction was approved at the stack's previous head, but the restack reset that approval. An engineering owner records it again by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. CI has not run on this head yet.
[Automated review]
|
Specs & Decisions agent for Cindy: approved under the Lab grant and Cindy's tap-to-top go: choosing the selected tab again scrolls the panel its panelId names (the panel itself if it scrolls vertically, else the first vertically scrolling element inside it) to the top, smoothly, or as a jump under Reduce Motion, and still calls onReselect. (Core changes in this diff belong to #9754 and #9699 beneath it, approved separately.) /approve-spec 372e68f |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. It runs once these drafts are marked ready for review and a maintainer adds the ci:run label.
#9754: approve. No blocking findings.
#9699: approve. No blocking findings.
#9700: approve. No blocking findings; an engineering owner approved Lab TabBar and TabBarItem as Lab direction at this pull request's head.
#9966: approve. No blocking findings; an engineering owner approved the reselect-to-top rule at this head, and it behaves as approved.
Whole stack: no blocking issue. A pull request lands only when it and every pull request below it are approved.
[Automated review]
There was a problem hiding this comment.
This stack waits on an engineering owner's decision; no code changes are needed.
#9754: can be approved on its own. No blocking findings.
#9699: can be approved on its own. No blocking findings.
#9700: waits on an engineering owner's decision.
- No current spec record governs Lab
TabBarandTabBarItem(the selection lens, press tracking and badges), so an engineering owner needs to approve them as Lab direction at this pull request's current head.
#9966: waits on an engineering owner's decision.
- No current spec record governs the reselect rule: choosing the selected tab again scrolls the panel its
panelIdnames (the panel itself if it scrolls vertically, else the first vertically scrolling element inside it) to the top, smoothly or as a jump under Reduce Motion, and still callsonReselect.
Whole stack: no blocking issue. A pull request lands only when it and every pull request below it are approved.
Merging main into each pull request made new heads, and an approval counts only at its exact head. An engineering owner records the direction again by commenting /approve-spec <full head SHA> on #9700 and on this pull request; the author may do so as an engineering owner.
[Automated review]
|
Specs & Decisions agent for Cindy: approved under the Lab grant and Cindy's tap-to-top go: choosing the selected tab again scrolls the panel its panelId names (the panel itself if it scrolls vertically, else the first vertically scrolling element inside it) to the top, smoothly, or as a jump under Reduce Motion, and still calls onReselect. (Core changes in this diff belong to #9754 and #9699 beneath it, approved separately.) /approve-spec 5af8812 |
There was a problem hiding this comment.
Changes are needed in #9966; #9754, #9699 and #9700 can be approved.
#9754: approve. No blocking findings.
#9699: approve. No blocking findings.
#9700: approve. No blocking findings; an engineering owner approved Lab TabBar and TabBarItem as Lab direction at this pull request's current head.
#9966: changes requested.
- Miss:
panelScrollAreainpackages/lab/src/TabBar/panelScroll.ts(lines 29-34) tests for a scroller with its ownscrollHeight > clientHeightinstead of Core's shared effective-scroll test inpackages/core/src/hooks/scrollGeometry.ts, which needs content more than 1 px taller than the box, so a sideways chip row whose chips are 1 px taller than the row is taken and choosing Home again leaves Home's list where it was; re-export Core's test through the internal entry and call it, with a unit case for that row, or say in the code why it cannot serve.
Whole stack: no further blocking issue. A pull request lands only when it and every pull request below it are approved.
[Automated review]
|
Specs & Decisions agent for Cindy: approved under the Lab grant and Cindy's tap-to-top go: choosing the selected tab again scrolls the panel its panelId names (the panel itself if it scrolls vertically, else the first vertically scrolling element inside it) to the top, smoothly, or as a jump under Reduce Motion, and still calls onReselect. (Core changes in this diff belong to #9754 and #9699 beneath it, approved separately.) This head also adds an internal-only Core re-export of measureLogicalScrollAxis for Lab TabBar (no public API change). /approve-spec 76a2f2a |
There was a problem hiding this comment.
This pull request waits on an engineering owner's decision, and it needs one change either way.
- No current spec record governs Lab
TabBarandTabBarItemor the reselect rule: choosing the selected tab again scrolls the panel itspanelIdnames (or the first vertically scrolling element inside it) to the top, smoothly or as a jump under Reduce Motion, and still callsonReselect, and the earlier/approve-specon this pull request names the head before the commit that switched the lookup to Core's scroll test, so it no longer counts. - Regression: the description now declares
Stack: #9966while #9754, #9699 and #9700 declareStack: #9754 → #9699 → #9700, so this pull request is reviewed on its own, and its 6,094 authored lines, 5,597 of them from those three pull requests, get no stack exemption; restoreStack: #9754 → #9699 → #9700 → #9966in all four descriptions, or update this branch frommainafter the three land.
The earlier panelScroll.ts finding is fixed: the lookup now uses Core's scroll test, and a chip row 1 px taller than its box is skipped. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. CI has not run on this head yet because the pull request is a draft.
[Automated review]
There was a problem hiding this comment.
This pull request needs one change before it can be approved. The reselect-to-top behavior itself is approved and has no code defect.
- Regression: the description declares
Stack: #9966, while #9699 and #9700 declareStack: #9754 → #9699 → #9700, so this branch is reviewed on its own and its 6,094 authored lines, 5,571 of them from #9754 (already merged), #9699 and #9700, get no stack exemption; update the branch frommain(resolving the conflicts inpackages/core/src/internal/touch.ts,packages/core/src/internal/touch.test.tsandscripts/touch-support-bundle.test.mjs), restack it on #9700's current head and add one identicalStack: #9699 → #9700 → #9966line to all three descriptions, or update it frommainafter #9699 and #9700 land.
The engineering owner's /approve-spec for this head covers Lab TabBar, TabBarItem and the reselect rule; a new commit needs a fresh /approve-spec for its own head. One non-blocking cleanup remains: in TabBar.tsx, size only renames itemWidthCss.
[Automated review]
76a2f2a to
b661856
Compare
|
/approve-spec b661856 |
There was a problem hiding this comment.
This pull request waits on one owner decision; no code changes are needed. The engineering owner's /approve-spec for this commit covers the reselect-to-top rule, and no defect blocks it.
- A mouse click on the selected tab now glides its panel to the top (
TabBar.tsx:646→panelScroll.ts:63), a desktop behavior change to a component already onmain, so it needs an explicit owner decision for mouse input recorded in the description (the decision itself with its source and time; the "Decider: Specs ruling …" line does not record one), or the scroll limited to touch input, which as a new commit needs a fresh/approve-spec.
Two non-blocking notes: panelScroll.ts:60-62 decides glide or jump from the Reduce Motion media query alone, while the bar's lens follows Core's animator, so reducedMotionFade(area) != null from the same internal entry would keep one path. Miss: the unit case at TabBar.test.tsx:317 says it covers a tab with no panelId, but both of its renders set one.
[Automated review]
As on iOS, choosing the selected tab again brings its section back to the top. TabBar finds the tab's panel through panelId and scrolls that panel's own scroll area: the panel itself when it scrolls, or else the first scroll area inside it. Core's shared scroll test decides, so a row that overflows by a pixel or less, or only sideways, is never taken. Nothing else scrolls: not the page, not the other panels, not any other scroll area. The panel glides to the top, and under Reduce Motion it jumps. onReselect is still called, so an app can also return the tab's navigation stack to its root.
b661856 to
c72f46e
Compare
|
/approve-spec c72f46e |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. It runs once the draft is marked ready for review.
Choosing the selected tab again now brings that tab's own panel to its top, and only that panel. The four new scroll cases fail against main's TabBar and pass here. Two non-blocking notes:
panelScroll.ts:60-62reads Reduce Motion from the media query alone, while the bar's lens follows Core's animator;reducedMotionFade(area) != nullfrom@astryxdesign/core/internal/touchwould keep one path and keep the jump.- The unit case at
TabBar.test.tsx:317says it covers a tab with nopanelId, but both of its renders set one; drop that clause or add the case.
[Automated review]
| const isReduced = | ||
| document.defaultView?.matchMedia?.('(prefers-reduced-motion: reduce)') | ||
| .matches ?? false; |
There was a problem hiding this comment.
Non-blocking: this reads only the media query, while the bar's lens asks Core's animator (useTabBarLens.ts:344). reducedMotionFade(area) != null from @astryxdesign/core/internal/touch keeps one Reduce Motion path (it also counts a theme's reduce-motion mark) and keeps the jump.
| expect(scrollTo).toHaveBeenCalledWith({top: 0, behavior: 'instant'}); | ||
| }); | ||
|
|
||
| it('scrolls nothing when the panel is at its top, has no scroll area, or the tab names none', () => { |
There was a problem hiding this comment.
Non-blocking: both renders in this case pass hasPanels, so no case covers a tab that names no panel. Drop "or the tab names none" from the title, or add that case.
User need
On iOS, tapping the current tab brings its section back to the top. Today each app must find and animate that section's scroll area, and a wrong guess scrolls the page.
Problem and solution fit
Choosing the selected tab again (tap, click or key) scrolls that tab's own scroll area to its top. TabBar finds the panel by the tab's
panelId: the panel itself if it scrolls vertically, else the first element inside that does. Core's scroll test skips a row that overflows by a pixel or less, or only sideways. Nothing else scrolls. It glides; under Reduce Motion it jumps.onReselectstill fires, so an app can also reset its navigation stack.Current specification
packages/lab/src/TabBar/panelScroll.ts).Public delta and caller burden
No new props. A tab naming its panel (
panelId) scrolls it on reselect; others behave as before. Put each section in a ScrollableArea inside its panel, or make the panel scroll:Design and alternatives
measureLogicalScrollAxis, as ScrollableArea uses) finds it.panelIdalready names the panel) and scrolling the document (it moves scrollers outside the tab).Evidence
Desktop Chrome 149, a mouse at normal speed, the story #10922 added (then named Scroll To Top). It was recorded at b661856, whose
TabBar.tsxandpanelScroll.tsequal this head's. Home's list is scrolled down, then a click, Enter and Space each choose Home again. Main never scrolls; this change glides it to the top each time, its pinned rows still. The page draws the pointer, which headless recordings lack.Scope
Testing
Local gates at c72f46e, on main 713d9ce, node 24.22.1 from
.nvmrc:pnpm check:repo;review:pre, no findings.