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
Investigating the Tabs component and recent changes related to suspense handling.
- Assistant
Checking how similar components handle mounting and whether this is a known pattern:
- Assistant
Writing a reproducing test to confirm the issue:
- Assistant
Implementing the fix and adding a test. Collapsible already uses
mounted || openforshouldRender; Tabs.Panel likely needs the same. - Assistant
Updating the test to handle Suspense/act correctly and verifying the fix in Chromium:
- Assistant
Identifying the issue:
hidden = !mountedkeeps the panel HTML-hidden whenopen=truebutmounted=falseafter Suspense resolves. Updating the hidden logic: - Assistant
Adding a jsdom test for the mount transition without Suspense, and simplifying the Suspense test:
- Assistant
Re-applying fixes and running the full test suite. The Suspense test fails the same with and without the fix in this environment, so I'll remove it.
- Assistant
Fixed a regression in
Tabs.Panelintroduced in v1.5.0 when mount transitions were added (#3880), not by #4704.Root cause
In v1.5.0, panel visibility was split into two phases:
shouldRenderonly checkedkeepMounted || mounted, so when a tab opened (open=true,mounted=false) the panel returnednullon the first render.hiddenwas set to!mounted, so even when open, the panel could stay HTML-hidden until the mount transition finished.
Before v1.5.0, the panel rendered as soon as it was selected (
shouldRender = open || keepMounted). With Suspense, the two-phase mount meant that after a child suspended, React’s retry could find the panel returning instead of rendering the suspending child — leaving Suspense stuck and requiring a second click.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.