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
Now let me look at the composite list infrastructure to understand tab registration:
- Assistant
Let me check what #4704 changed in TabsRoot:
- Assistant
Now let me add a repro test to confirm the diagnosis:
- Assistant
All jsdom tests pass. Let me also run the Chromium env since 26 tests are skipped in jsdom:
- Assistant
All checks pass. Final review of the changes:
- Assistant
The fix is complete. Summary:
Root cause
The regression came from #4704, which added an automatic fallback in
TabsRoot: when the tab registration map becomes empty after tabs had registered, the value is committed tonullwith reason'missing'(previously the effect just bailed out whentabMap.size === 0).When a panel child suspends and the nearest
Suspenseboundary is outsideTabs.Root, React doesn't unmount the tree — it hides it (keeping the DOM nodes connected withdisplay: none) and destroys its layout effects. That destroys each tab's registration effect, transiently emptyingtabMap. When the tree reappears, the fallback effect ran with the empty map before the tabs re-registered and committedvalue = null, deselecting the tab the user had just clicked. That's why the panel only appeared on the second click.Fix (
packages/react/src/tabs/root/TabsRoot.tsx)TabsRootnow keeps a snapshot of the most recently registered tab elements. When the registration map is empty, it distinguishes the two cases viaisConnected:- Tabs genuinely removed → their elements are disconnected from the DOM → commit the
null/'missing'fallback as before. - Tree hidden by a suspended descendant → the elements are still connected → keep the current selection; the tabs re-register when the tree reappears.
Verification
- New regression test in
TabsRoot.test.tsx(Suspense integration) reproducing the issue's exact scenario — failed before the fix (both tabs ended uparia-selected="false"with no panel), passes after. - All 210 Tabs tests pass in both jsdom and Chromium, including the existing
'missing'-fallback tests for genuinely removed tabs. pnpm typescript,pnpm eslint, andpnpm prettierall pass.
- Tabs genuinely removed → their elements are disconnected from the DOM → commit the
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 →
- gpt-5.6-solCompare side by side →
- fable-5Compare side by side →
- fable-5Compare side by side →