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 v1.5 tabs mounting change against the current tests, then patch and add a focused suspension regression test. I’ll first read the repository contribution guidance as required.
- Assistant
rgisn’t installed in this checkout, so I’m usingfind/grepfor the same inspection. The contribution guide adds no tabs-specific constraints beyond the supplied repository instructions. - Assistant
The regression is in the root’s automatic “missing tab” fallback: when the outer Suspense boundary hides the tabs, React temporarily detaches tab refs, making the registered tab map empty. The root mistakes that transient state for all tabs being removed and clears the selected value. I’m inspecting the composite registration lifecycle to distinguish transient ref loss from a real removal without weakening the existing missing-tab behavior.
- Assistant
The focused test now reproduces the failure: during the suspended interval, the selected tab falls back to Tab A even though Tab B’s DOM node still exists in React’s hidden primary tree. The clean discriminator is node connectivity—real tab removal disconnects its node, while Suspense only unregisters layout effects and keeps the hidden node connected. I’m adjusting registration state to retain connected tabs across that temporary cleanup.
- Assistant
The exact
React.use(promise)reproduction isolates the issue to panel mounting, not tab registration.useTransitionStatusraisesmountedvia a render-phase state update; when that render suspends, React discards the update, so retries continue returningnull. The fix is to render whenever the panel is currently open as well as when its transition-mounted state is set. - Assistant
The suspended render can discard the uncontrolled state update itself; removing panel transition logic and automatic fallback logic independently did not prevent it. I’m making the latest accepted uncontrolled selection available synchronously via a ref (updated only after cancellation checks), while retaining normal state for committed renders and preserving controlled behavior. This prevents Suspense retries from reverting to the last committed tab.
- Assistant
The failing stack now confirms the concurrency conflict: Suspense’s layout-effect cleanup synchronously unregisters composite items and the mounted panel, scheduling updates inside the hidden root while the Tab B update is suspended. Those cleanup updates supersede the pending selection. I’m deferring unregistration until the commit finishes and only unregistering nodes that were genuinely disconnected; Suspense-hidden nodes remain connected.
- Assistant
The regression test now passes, and the existing Tabs.Root suite still passes, including real tab removal and
aria-controlscleanup. The implementation is confined to composite unregistration: it waits one microtask, then updates only if the element was actually disconnected, so Suspense cleanup no longer generates a competing root update. I’m running the broader tabs suite plus formatting, lint, and types next.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.