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:
codeimport { 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
- Assistant
I’ll trace the Tabs changes around panel mounting and suspension, first reviewing the repository contribution guidance as required, then add a regression test and verify the focused suites.
- Assistant
rgisn’t installed in this workspace, so I’m usingfind/grepfor the same read-only inspection. I’m narrowing this to the panel’s “render only after first activation” state, which is the likely state lost when React abandons a suspended render. - Assistant
I found a useful precedent in the collapsible implementation: its render gate explicitly includes the current open state, so rendering does not depend solely on a render-phase transition-state update surviving suspension. I’m first codifying the exact Tabs regression to confirm that the same invariant is missing here.
- Assistant
The exact
use(promise)reproduction fails on the current code, whileReact.lazydoes not—matching the report closely. The suspended render loses the panel’s render-phasemountedupdate, leaving the selected panel gated out on retry. I’m applying the narrow fix: selected/open panels render regardless of that transition bookkeeping state, while closed panels still respect exit animations andkeepMounted. - Assistant
The panel render gate alone isn’t sufficient. The deeper regression is in the v1.5 automatic-selection logic: when the outer Suspense boundary hides the tab tree, tab registration layout effects temporarily unregister every tab;
Tabs.Rootinterprets that transient empty registry as “all tabs were removed” and changes its value tonull. I’m adjusting registry handling to retain the last map only while those tab DOM nodes are still connected—the signature of Suspense hiding—while real tab removal still produces the required missing-value fallback. - Assistant
The focused regression now passes with a test harness that keeps the suspend/resolve cycle inside React’s async test scope. I’m validating the test’s sensitivity against the original implementation, then I’ll restore the fix and run the broader Tabs suites plus formatting, lint, and type checks.
- Assistant
All 210 focused Tabs tests pass in jsdom. Chromium verification is unavailable because the local Playwright browser binary is missing; I won’t download it because the task explicitly excludes internet/external sources. I’m finishing with the repository’s formatting, lint, and TypeScript checks.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.