ISSUE DESCRIPTION [tabs] Tabs.Panel content not rendered if a child component suspends…
- User
ISSUE DESCRIPTION
[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
- Assistant
I’ll inspect the repository history and Tabs implementation, identify the v1.5.0 change around suspense/lifecycle behavior, then reproduce with the relevant tests or a focused test harness. I’ll modify only source code, run affected tests, review the diff, and submit once verified.
- Assistant
The repository is clean, but ripgrep is unavailable, so I’ll use the available Unix tools. I’m locating the Tabs source and recent commits first, especially code that controls panel mounting and activation after a suspended render.
- Assistant
The likely regression is in
TabsRoot, which tracks mounted panels and was changed by the referenced #4704 commit. I’ll compare that commit with its parent and inspect panel/root registration effects to understand how a suspended subtree leaves state stale. - Assistant
The regression mechanism is now clear: when the outer Suspense fallback removes the Tabs subtree, the new “no tabs remain” branch interprets the transient empty composite map as a real removal and sets the uncontrolled value to
null. On retry, the selected panel is no longer active, so the first click is lost. I’ll preserve the legitimate “all tabs were removed” behavior while skipping that fallback when the root DOM element is currently detached by Suspense. - Assistant
The first edit-and-test command was rejected because of a shell quoting mistake, so no repository change was made. I’ll rerun the edit with a correctly quoted command, then execute the Tabs test file.
- Assistant
The source edit succeeded; the test command timed out because Corepack attempted to download pnpm interactively. I’ll avoid that prompt by invoking the repository’s local Vitest binary directly, and first inspect the resulting diff/type compatibility.
- Assistant
The existing Tabs tests pass on the unchanged source, confirming the baseline suite is healthy. The timed-out command had not persisted the edit (the process was terminated before the Python step completed), so I’ll apply the small change separately and rerun the same suite.
- Assistant
This environment does not provide Python (the earlier command never reached its Python step). I’ll use Node, which is available, to make the exact same source edit without touching tests.
- Assistant
The fix is applied and the full existing
TabsRootsuite passes (103 tests, 26 skipped). The change keeps the existing null fallback for a genuinely mounted root whose tabs were removed, but avoids it when the root ref is absent during Suspense detachment. I’ll run a TypeScript check if available and review status/diff before submission.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.