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 and the referenced behavior locally, starting with the repository contribution rules, then add a regression test and fix the underlying state/lifecycle issue.
- Assistant
rgisn’t installed in this checkout, so I’m using targetedfind/grepsearches. The contribution guide adds no Tabs-specific constraints beyond the supplied instructions. - Assistant
The regression appears tied to the automatic-selection effect introduced in v1.5.0: when an outer Suspense boundary hides the Tabs subtree, tab registrations temporarily disappear, and Tabs interprets that transient state as “all tabs removed,” overwriting the clicked value. I’m pinning that behavior with a regression test before changing the effect.
- Assistant
The exact
use(promise)repro now fails locally and confirms the cause: React preserves the suspended Tabs DOM but disconnects its layout effects, so the composite registry temporarily reports the selected tab as missing. The fix will ignore only that transient “missing” signal when the previously registered selected tab is still connected; genuine tab removal remains detectable. - Assistant
The registry’s fallback effect was only the downstream symptom. Instrumentation shows the actual interruption happens earlier: composite item layout-effect cleanup synchronously updates the registry while React has merely hidden (not removed) the suspended subtree. I’m moving that cleanup past the commit and retaining entries whose DOM nodes remain connected, which lets React retry the original tab selection.
- Assistant
The browser regression test now cleanly distinguishes the behavior: the v1.5 automatic-selection logic sees a zero-sized tab registry during Suspense’s layout-effect disconnection and commits
null. The older logic skipped zero-sized registries. I’m preserving the newer “last tab truly removed” behavior by checking whether the previously registered tab nodes are still connected before treating the empty registry as real removal. - Assistant
The focused fix passes the full Tabs suite in jsdom (172 passing) and the regression passes in Chromium using the installed system browser. I’m doing the repository-wide formatting/type/lint checks now and verifying the final diff contains only the Tabs fix and regression test.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.