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
Let's write a temp test file to reproduce the issue using vitest.
Assistant
Now let's disable the console.error failure for this test run and check logs, and mock console appropriately.
Assistant
Now let's remove the earlier PANEL RENDER log (keep it, it's fine) and run again to see instance identity and mount/unmount events plus tabMap-size transitions.
Assistant
Now let's implement the actual fix in TabsRoot.tsx.
Assistant
Now let's edit the effect body around lines that had shifted by 1 (due to added import line).
Assistant
Now let's make the edit:
Assistant
Now let's add
emptyTabMapFrameto the effect dependencies array for lint hygiene.Assistant
Now let's verify the full effect region compiles well and re-run our repro test.
Assistant
Now let's copy the repro test back and run it to check.
Assistant
The fix works. Now let's remove the repro test and run the full existing Tabs test suite to make sure nothing broke.
Assistant
All existing Tabs tests pass. Now let's run the broader test suite for related components (composite, internals) to check nothing else broke, plus lint check.
Assistant
Now let's check TypeScript compiles and run eslint on the changed file.
Assistant
Confirmed pre-existing environment issue, unrelated to our change. Let's just do a targeted type-check with plain
tsc --noEmitwithout project references using a standalone check, or run eslint instead.Assistant
No eslint errors. Let's also run full test suite for
packages/reactbroadly to check nothing else regressed (quick sanity subset), plus double check the diff.Assistant
All 263 test files pass (6259 tests passed, 0 failed). Let's do a final review of the diff.
Assistant
This looks clean. Let's run the full Tabs test suite once more plus the reproduction scenario one final time to be certain, then clean up any leftover temp files.
Assistant
No leftover temp files, and all tests pass. Let's do final diff review.
Assistant
The changes look complete and clean. Let me go through the checklist:
Checklist review:
-
If an error was reported in the issue description, I have successfully reproduced it. ✅ I reproduced the issue with a vitest test that mirrors the Stackblitz example (Tabs.Root wrapped in Suspense, with a child in Tabs.Panel that suspends without its own boundary). I confirmed via instrumentation that clicking a tab causes the whole tab list to transiently unregister and re-register (due to React's Suspense hide/reveal effect-cleanup cycle), which made briefly hit . The buggy code (from PR #4704) interpreted that transient blip as "all tabs were permanently removed" and force-committed , which is why the panel content never appeared even after the promise resolved.
-
Assistant
Now I'll submit this change.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.