SWE-Rebench v2 hard task
harbor run -t ibragim-badertdinov/mui__base-ui-4903harbor download ibragim-badertdinov/mui__base-ui-4903[tabs] Tabs.Panel content not rendered if a child component suspends without boundary within Tabs.Root
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.Root component), 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.
The panel content is rendered also when first opening a tab like it did in v1.4.1.
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>
);
}
The only affected version is v1.5.0
v1.4.1 is not affected
Reproducible in Chrome/Safari/Firefox
Potentially a side effect of https://github.com/mui/base-ui/pull/4704
No new interfaces are introduced.