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 reproduction script/test using createRenderer, to test the described scenario.
Assistant
Also let's log mount/unmount of TabsRoot with an effect.
Assistant
Let's add detailed logging via node script modifying the file directly with sed/edit.
Assistant
Bash tried to expand the
!in double quotes. Let me fix the botched edit properly.Assistant
Now let's also log the "selectionIsMissing" branch.
Assistant
Now let's implement the actual fix in TabsRoot.tsx.
Assistant
Now let's update the effect branch for
tabMap.size === 0.Assistant
There's an extra
}at line 321. Let me fix that.Assistant
The fix works. Now let's run the full Tabs test suite (jsdom and chromium) to ensure nothing broke.
Assistant
All Tabs tests pass. Let's also run in chromium (browser) mode since that's default test target, to be thorough.
Assistant
Network works. Let's re-run chromium tests.
Assistant
All pass in real Chromium too. Now let's also run the entire react package test suite (broader) to check for unintended side effects, at least jsdom for speed.
Assistant
All tests pass across the whole react package. Let's view the final diff.
Assistant
Good,
queueMicrotaskis an established pattern in this codebase, consistent with our fix. Let's view the final diff once more in full context for review.Assistant
Now line 360 (
return;aftercommitAutomaticValueChange) and the final implicit fall-through need updating too.Assistant
Now let's re-run eslint on this file.
Assistant
No lint errors now. Let's re-run tests to make sure everything's still fine.
Assistant
All tests pass. Let's re-run the reproduction test once more to confirm the fix still works with the lint-fixed code, then clean up and check TypeScript compile.
Assistant
Now let's check TypeScript typechecking for the package.
Assistant
Type checking passes cleanly. Let's do a final review of the diff.
Assistant
This looks clean and minimal. Let's run the full test suite once more (both jsdom and chromium) plus lint across the whole repo to be safe, and check for any stray leftover debug files.
Assistant
No stray files. Let's do a final full check running the whole react test suite in chromium too (already did jsdom fully; let's run chromium fully to be thorough given the change touches core Tabs logic).
Assistant
Everything passes. Let's review the checklist items now.
Assistant
Assistant
This is my final solution. Submitting now.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.