Untitled conversation
- User
[tabs] Tabs.Panel content not rendered if a child component suspends without boundary within Tabs.Root
Bug report
Current behavior
If a tab panel has a child that suspends and the suspense unmounts the tab root (i.e., the next boundary is outside the
Tabs.Rootcomponent), the panel content is not rendered when opening a tab for the first time.Only when clicking the trigger a second time, the panel is rendered.
Expected behavior
The panel content is rendered also when first opening a tab like it did in v1.4.1.
Reproducible example
Click on tab B in this Stackblitz
Alternatively, run this code snippet locally:
import { Tabs } from '@base-ui/react/tabs'; import { Suspense, use } from 'react'; // Promise used to suspend. const dataPromise = new Promise<string>((resolve) => setTimeout(() => resolve('Panel B is rendered'), 500) ); function SuspendingChild() { return <div>{use(dataPromise)}</div>; } export default function App() { return ( // The Suspense boundary is outside the <Tabs.Root> and the panels/panel content don't use a separate suspense boundary. <Suspense fallback={<div>Loading…</div>}> <Tabs.Root defaultValue="a"> <Tabs.List> <Tabs.Tab value="a">Tab A</Tabs.Tab> <Tabs.Tab value="b">Tab B</Tabs.Tab> </Tabs.List> <Tabs.Panel value="a">Panel A (no suspense)</Tabs.Panel> <Tabs.Panel value="b"> <SuspendingChild /> </Tabs.Panel> </Tabs.Root> </Suspense> ); }Base UI version
The only affected version is v1.5.0
v1.4.1 is not affected
Which browser are you using?
Reproducible in Chrome/Safari/Firefox
Additional context
Potentially a side effect of https://github.com/mui/base-ui/pull/4704
Interface
No new interfaces are introduced.
- Assistant
I’ll trace the Tabs changes around panel mounting and suspension, starting with the contribution guidelines, then add a regression test and verify the focused suites.
- Assistant
rgisn’t installed in this checkout, so I’m usingfind/grepfor the repository trace. I’m narrowing the regression to the panel’s render/mount bookkeeping introduced in the affected release. - Assistant
The failure mechanism is now clear: when the outer Suspense boundary hides the Tabs subtree, tab registration effects disconnect and briefly report an empty tab map. The new automatic “missing selection” logic interprets that transient state as all tabs being removed and resets the selected value to
null. I’m capturing that exact lifecycle in a regression test before changing the fallback logic. - Assistant
The fix now ignores a missing-selection snapshot only when the previously registered matching tab is still connected—precisely the Suspense effect-disconnection case. Truly removed tabs remain disconnected, so the existing automatic fallback and
onValueChange(..., reason: 'missing')behavior is preserved. - Assistant
The regression test confirms React keeps the Tabs root connected but marks it
display: none !importantwhile the outer boundary shows its fallback. I’m using that Suspense-hidden state to suppress only the transient missing-tab fallback; once revealed, normal registrations resume. - Assistant
I’m switching the guard to the tab elements’ ref lifetime. Suspense disconnects layout effects (which empties the composite registration map) but retains host refs; actual tab removal clears the ref. That gives Tabs an exact distinction without timing or DOM-style heuristics.
- Assistant
Host refs are also detached by this Suspense transition, so they cannot distinguish it from removal. The reliable ordering fix is to keep non-empty-map fallback synchronous, but defer only the “all tabs disappeared” decision to a passive effect. On Suspense reveal, tab layout registrations are restored before that passive effect; a real removal remains empty and still resolves to
null. - Assistant
The regression now passes, including the existing case where removing the last real tab still emits a
missingchange and selectsnull. I’m doing the repository-level type, lint, and formatting checks next; Chromium execution is currently unavailable because the local Playwright browser binary is absent. - Assistant
TypeScript, full ESLint, formatting, and the complete TabsRoot jsdom suite are clean. I’m running the broader Tabs jsdom selection and one final diff check now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- composer-2.5Compare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →