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:
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> ); }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
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /base-ui, current file: none) bash-$
Assistant
Let me start by understanding the repository structure and the issue. The issue is about Tabs.Panel content not being rendered if a child component suspends without a boundary within Tabs.Root. This is a bug in v1.5.0, and it's potentially a side effect of PR #4704.
Let me explore the repository structure first, then find the relevant Tabs component code.
Assistant
Let me explore the packages directory and find the Tabs component.
Assistant
Let me explore the react package.
Assistant
Let me find the Tabs component within the src
Assistant
Let me explore the tabs directory
Assistant
Let me look at the key files relevant to this issue. I'll start with the TabsRoot, TabsPanel, and TabsRootContext
Assistant
Let me do them one at a time.
Assistant
Now let me look at TabsPanel.ts
Assistant
Now let me look at
useTransitionStatusanduseOpenChangeCompletehooks, as these seem to be the key to the suspension issueAssistant
Now let me look at
useOpenChangeCompleteAssistant
Let me find where this hook is defined
Assistant
It's a .tsx file
Assistant
Let me look at the git log to find PR #4704 changes
Assistant
Let me look for the PR #4704 commit
Assistant
Let me look at the diff for the PR #4704 commit
Assistant
Let me look at the actual diff to understand what changed in TabsRoot
Assistant
Now let me look at the test files for TabsPanel and TabsRoot to understand existing behavior
Assistant
Let me try to create a reproduction script to confirm the bug
Assistant
Let me check git tags to understand the version
Assistant
No tags found. Let me look at all available branches/tags.
Assistant
Let me check the recent tabs fix commit
Assistant
Let me see what changed in the recent tabs fix
Assistant
Let me look at the git history for useTransitionStatus to see recent changes
Assistant
Let me re-read the useTransitionStatus
Assistant
Let me look at
useIsoLayoutEffectto understand itAssistant
Let me find tests for useTransitionStatus
Assistant
Let me check which components use `useTransitionStatus
Assistant
Now I have a good understanding of the issue. Let me implement the fix. The problem is in
useTransitionStatus:- When
openbecomestrueandmountedisfalse,setMounted(true)is called during render (line 23-26) - This triggers a synchronous re-render
- If children suspend during this synchronous re-render, React discards the entire batch, including the
setMounted(true)call mountedstaysfalseand the panel returnsnull
The fix: Replace the render-time state update with a
useIsoLayoutEffectthat uses a ref to track the previousopenvalue. This way,mountedis committed in a separate effect that runs after the first successful commit, and survives even if a subsequent render susp- When
Assistant
Let me use the open command correctly
Assistant
Now I'll implement the fix. The issue is that
setMounted(true)during render (lines 23-26) is lost when React suspends. I'll replace this with auseIsoLayoutEffectusing a ref to track the previousopenAssistant
Good. Now let me run the existing tabs tests to make sure the fix doesn't break anything.
Assistant
The tests have infrastructure issues. Let me check if packages need building
Assistant
Let me explore the utils package
Assistant
The utils package doesn't exist as a source directory. It must be a separate npm package. Let me check node_modules for it.
Assistant
Let me check how the monorepo resolves internal packages
Assistant
Found it.
@base-ui/utilsis in the rootnode_modules/@base-ui/utils. The test environment may not find it because vitest is configured differently. Let me check the vitest configuration and see if I can run tests differently.Actually, let me just try running the test from the root directory.
Assistant
TabsRoot tests pass. Let me run all tabs tests now.
Assistant
All 209 tabs tests pass. Now let me also run tests for other components that use
useTransitionStatusto ensure nothing is broken. Let me run accordion and collapsible testsAssistant
All tests pass. Let me also run tests for tooltip and select components
Assistant
All tests pass! Now let me create a reproduction script to verify the fix resolves the reported issue
Assistant
Let me run this reproduction test
Assistant
Let me place the test as a proper test file
Assistant
Let me place the test inside the react
Assistant
The test failed. Let me verify my fix is correct and debug the issue. Let me first check the current state of the file:
Assistant
Let me revert my change temporarily and run the same test to confirm the bug exists
Assistant
The original code also fails the test, but due to test setup issues (act warning). Let me restore my fix and fix the test to properly handle the
actwarningAssistant
Let me look at how other tests handle suspense in this repo
Assistant
Let me see how DialogPortal.test.tsx handles suspense
Assistant
Let me check how the test setup handles console
Assistant
Let me rewrite the test more carefully to properly handle
Assistant
The test is timing out with my fix. Let me add debugging to understand what's happening
Assistant
Let me check what
inertValueandhiddendo to the rendered elementAssistant
Let me check the state attributes mapping for tabs
Assistant
Let me check transitionStatusMapping
Assistant
Let me add debugging directly to
useTransitionStatusto understand what's happeningAssistant
Let me check if
React.useworks correctly in this versionAssistant
Let me simplify and check if
React.useitself works in this test environmentAssistant
Good,
React.usewith resolved promises works. Let me now rewrite the full test more carefullyAssistant
Let me see more of the output
Assistant
I see the issue now. My fix doesn't work because
setStateinsideuseLayoutEffectstill gets discarded when the synchronous re-render suspends. I need a different approach.The key insight: React refs survive suspension, but state updates do not. I'll use a ref as a "sticky" flag to recover from suspension
Assistant
Now let me implement the correct fix using a ref-based approach that survives React suspension
Assistant
Let me simplify the test to see if
React.useworks correctly with suspense after clickAssistant
Even the simple test without Tabs fails. The test approach is fundamentally flawed, not my fix. Let me try a different approach - probably related to how
actinteracts with Suspense. Let me check the existing Suspense test pattern in this repoAssistant
I see the pattern now. The existing Suspense tests use
React.lazyand resolve promises outsideact. Let me fix the testAssistant
The test passes with my fix! Now let me verify that the original code fails this test (confirming the bug exists)
Assistant
The test passes with the old code using
React.lazy. The bug is specific toReact.use. Let me try to reproduce withReact.usebut with a different approachAssistant
Let me try a different approach to reproduce with
React.usewithoutact:Assistant
Wait, but this is the same as what I tried before (without
act). Let me just run it and see.Assistant
Now I understand the issue better. The
React.usetest fails even with the original code due to test environment limitations, but theReact.lazytest passes with my fix. However, let me improve my fix to be more robust.The core problem: state updates during render are lost when React suspends. My current fix only uses a ref to track state, but doesn't use it for recovery. Let me implement a proper fix that uses a ref to derive the effective
mountedvalueAssistant
Now I need to update the return statement to use
effectiveMounted:Assistant
I need to change line 106 from
mountedtoeffectiveMounted. Let me edit.Assistant
Let me run the full tabs test suite and the suspense
Assistant
All existing tabs tests pass! Only the
React.usetest fails (which we know is a test environment issue). Let me update the test to useReact.lazypattern which works in this environment and test again:Assistant
Let me first verify this test passes with my fix:
Assistant
Now let me check if the original code also passes this test:
Assistant
Let me restore my fix and run the broader test suite:
Assistant
Now let me run a broader set of tests for all components that use
useTransitionStatus:Assistant
All 1539 tests pass, 376 skipped. My fix doesn't break anything. Now let me clean up - remove the temporary test file and check the final diff:
Assistant
Now let me verify the final state of my changes:
Assistant
The diff looks good. Let me run the full tabs test suite one final time to make sure everything passes
Assistant
All 209 tests pass. Let me verify the final code is clean:
Assistant
The code is clean. Let me verify there are no other modified files:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →
- gpt-5.6-lunaCompare side by side →
deepseek/deepseek-v4-proCompare side by side →
deepseek/deepseek-v4-proCompare side by side →