Skip to content

fix(lab): write the TabBar lens refs at commit, not in render - #10813

Closed
vjeux wants to merge 1 commit into
meta:mainfrom
vjeux:fix/tabbar-lens-refs-at-commit
Closed

vjeux wants to merge 1 commit into
meta:mainfrom
vjeux:fix/tabbar-lens-refs-at-commit

Conversation

@vjeux

@vjeux vjeux commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

User impact

People using Lab's TabBar in an app that renders with transitions. useTabBarLens copied selectedIndex, onLift and isDisabled into refs during render, and its press-ending function too. A render React discards, as a suspended transition does, left them there for the next press:

  • A lift could deliver its choice through a discarded render's onLift, which TabBar builds over that render's items.
  • The lens could chase the selected tab, or skip a disabled one, as a discarded render saw them.
  • A change to the tab list could end a held press with a discarded render's function.

Problem and solution fit

The press, its moves and the lift run later, against the committed bar. A write during render runs for every render, including the ones React throws away, so they read props from a screen nobody saw.

Each ref is now written in a one-line layout effect, with a note naming what it syncs. The press-ending function's effect comes before the tab-list effect that calls it.

Expected behavior and authority

Smallest restoration

Four refs in useTabBarLens.ts. No API, visual or default changes.

Evidence

  • Reproduction before the change: no unit test can show it. The lens's press and lift run on the shared gesture tracker and hit-test real layout, which jsdom lacks. TabBar's unit tests drive no pointer events.
  • Result after the change, at 160798b: the TabBar interaction spec, which drives the press and the lift, passes in both engines.
  • Representative unchanged path: TabBar's unit tests pass.
  • Regression test or other mutation-sensitive proof: none, for the reason above.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

All runs below are at this PR's head, 160798b.

Ref Written now Why there
selectedRef Layout effect Mirrors the selectedIndex prop. No handler here sees it change.
onLiftRef Layout effect Mirrors the onLift prop, which TabBar builds each render.
isDisabledRef Layout effect Mirrors the isDisabled prop.
endRef Layout effect, before the tab-list effect Holds this render's press-ending function, which no handler sets.
  • pnpm exec vitest run packages/lab/src/TabBar --project ui: 3 files, 68 tests pass.
  • TabBar interaction spec, 1 worker: Chromium 63 passed; WebKit in the CI-profile container 53 passed, 10 skipped.
  • @astryxdesign/lab typecheck, source and docs: 0 errors. ESLint and Prettier on the changed file: clean.

A parked draft, #9701, touches the same lines: its ref block and its press-ending block. Its owner prefers that whichever lands second takes the short rebase.

useTabBarLens copied selectedIndex, onLift and isDisabled into refs
during render, and its end-of-press function too. A render React
discards, as a suspended transition does, left its values there for
the press, the lift and the tab-list effect.

Each ref is now written in a one-line layout effect, and the press
ending's comes before the effect that reads it.
@vercel

vercel Bot commented Nov 9, 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 9, 2026 3:40pm UTC

Request Review

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

astracat-bot Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🔄 In progress (for maintainers only) Nov 9, 2026, 3:32 PM UTC

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 9, 2026
@vjeux

vjeux commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Closed per the spec owners: folds into the next TabBar lens PR as a tidy.

@vjeux vjeux closed this Nov 9, 2026

This branch was successfully deployed

1 active deployment
Preview — 160798b6 Deployed Nov 9, 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 A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) 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.

2 participants