Skip to content
TheChatArchiveThe Chat Archive
xiaomi/mimo-v2.5-pro· unknownHugging Face ibragim-bad/swe_rebench_07_2026_trajectories

ISSUE DESCRIPTION [tabs] Tabs.Panel content not rendered if a child component suspends…

  1. 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.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.

    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

    Interface

    No new interfaces are introduced.

    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 using git reset --hard command. Additionally, you can use git stash and git stash pop to temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you call submit) using git status or git diff commands. However you don't need to use git add or git commit before submitting your changes. In fact, submit only submits currently unstaged changes because it uses git diff to 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-$

  2. Assistant

    I'll start by exploring the repository structure to understand the codebase. Let's first see what's in the root directory.

  3. Assistant

    Let me explore the repo structure more broadly first.

  4. Assistant

    Let me explore the packages directory and find the Tabs component.

  5. Assistant

    Let me find the Tabs component code.

  6. Assistant

    Let me look at the Tabs component source code.

  7. Assistant

    Let me look at the tabs panel and root components.

  8. Assistant

    Let me examine the TabsPanel and TabsRoot components:

  9. Assistant

    Now let me look at the useTransitionStatus hook since it's mentioned in the issue that the panel content is not rendered when opening a tab for the first time:

  10. Assistant

    Let me look at the PR #4704 mentioned in the issue to understand what changed:

  11. Assistant

    Let me look at the specific commit for the tabs fix that might be relevant.

  12. Assistant

    The issue mentions PR #4704 as potentially causing the issue. Let me look at that commit.

  13. Assistant

    Let me look at the commit 2540428f0 which is the PR #4704 that was mentioned as potentially causing the issue.

  14. Assistant

    Let me look at the changes to TabsRoot.tsx in that commit:

  15. Assistant

    Now let me look at the current state of TabsRoot.tsx:

  16. Assistant

    Let me now understand the useOpenChangeComplete hook and the useTransitionStatus hook in more detail, since these are involved in the panel rendering logic:

  17. Assistant

    Let me find this file.

  18. Assistant

    Let me look at the issue more carefully. The problem is:

    1. A tab panel's child component suspends (uses React Suspense)
    2. The Suspense boundary is outside of Tabs.Root
    3. When opening a tab for the first time, the panel content doesn't render
    4. It works on the second click

    The key thing here is how useTransitionStatus and useOpenChangeComplete interact with React Suspense.

    Let me look at the useOpenChangeComplete hook first.

  19. Assistant

    Now let me look at useTransitionStatus more carefully. The key issue seems to be around how mounted state interacts with Suspense boundaries. Let me trace through what happens when a child suspends.

  20. Assistant

    Now let me look at how useControlled works and how the Tabs component uses the Tab click handler.

  21. Assistant

    Let me look at the recent fix commit for tabs state edge cases, as it might be related to this issue:

  22. Assistant

    Let me look at how tab clicks are handled:

  23. Assistant

    Now let me understand the issue better. The problem is that when a child component inside a Tabs.Panel suspends (React Suspense), and the Suspense boundary is outside Tabs.Root, the panel content isn't rendered on first open. This only works on the second click.

    Let me look at the useTransitionStatus hook more carefully, as this seems to be key:

  24. Assistant

    Let me look at the key issue more carefully. The PR #4704 introduced didRegisterTabsRef which tracks whether tabs were ever registered. Let me look at how the useIsoLayoutEffect interacts with Suspense:

  25. Assistant

    Let me look at the useControlled hook and the useIsoLayoutEffect that handles automatic tab selection:

  26. Assistant

    Let me look at the useControlled hook to understand how state management works with the controlled/uncontrolled pattern.

  27. Assistant

    Now let me understand the flow better. Let me look at how the CompositeList updates the tab map:

  28. Assistant

    Let me look at the CompositeList component:

  29. Assistant

    Let me look at useCompositeListItem to understand how tabs register/unregister:

  30. Assistant

    Let me look at the existing tests for TabsPanel and TabsRoot to understand the test patterns:

  31. Assistant

    Let me look at the most recent tabs fix commit for clues:

  32. Assistant

    Let me focus on understanding the exact flow. Let me look at how the useTransitionStatus hook interacts with Suspense:

  33. Assistant

    Let me create a reproduction to understand the exact issue. First, let me look at the existing test patterns and how tests are run:

  34. Assistant

    Let me create a reproduction script to understand the exact issue:

  35. Assistant

    Let me understand the issue better by looking at the test patterns and then creating a reproduction:

  36. Assistant

    Let me focus on creating a reproduction script to verify the exact behavior:

  37. Assistant

    Let me trace the exact problem. I'll look at the CompositeList component and how sortedMap interacts with the isConnected filter:

  38. Assistant

    Now I understand the issue. Let me trace the exact flow carefully. Let me look at the useIsoLayoutEffect in the useTransitionStatus hook and see how it interacts with useOpenChangeComplete:

  39. Assistant

    Now I have a good understanding of the codebase. Let me trace through the exact issue. The problem is in the useTransitionStatus hook and how it interacts with Suspense. Let me verify my hypothesis by looking at the code flow more carefully:

  40. Assistant

    Now I have a thorough understanding of the code. Let me trace through the exact issue:

    When a child inside Tabs.Panel suspends and the Suspense boundary is outside Tabs.Root:

    1. Click Tab B → setValue("b") committed
    2. React renders Panel B with open=true
    3. useTransitionStatus calls setMounted(true) during render (render-phase state update)
    4. Panel renders, child suspends
    5. React catches at the Suspense boundary outside Tabs.Root
    6. The render-phase state update (setMounted(true)) is NOT committed - React reverts to committed state (mounted=false)
    7. When promise resolves, React retries the render
    8. Panel B: open=true, mounted=false → setMounted(true) called again
    9. This time child doesn't suspend → render completes → mounted=true committed
    10. Panel should show with hidden=false

    This should work, so the issue must be elsewhere. Let me look at the PR #4704 change more carefully - specifically the tabMap.size === 0 check:

  41. Assistant

    Let me look at the existing tests for patterns and create a reproduction:

  42. Assistant

    Let me now create a test to reproduce the issue. I'll write a focused reproduction:

  43. Assistant

    Let me trace the actual issue more carefully by looking at what happens step by step. I think the core problem is in the interaction between CompositeList's sortedMap (which filters disconnected nodes) and the useIsoLayoutEffect in TabsRoot. Let me verify my theory by looking at what happens when the Suspense boundary catches:

  44. Assistant

    Now I understand the issue. Let me trace through the exact flow:

    1. User clicks Tab B → setValue("b") committed
    2. Panel B starts rendering with open=true, useTransitionStatus sets mounted=true
    3. SuspendingChild suspends (throws promise)
    4. React catches at the Suspense boundary outside Tabs.Root
    5. React shows the fallback — the Tabs.Root tree is removed from DOM
    6. The CompositeList's MutationObserver detects DOM changes, triggering sortedMap recomputation
    7. sortedMap filters by node.isConnected — all nodes are now disconnected → sortedMap is empty
    8. onMapChange(emptyMap) → setTabMap(emptyMap) → tabMap.size === 0
    9. TabsRoot's layout effect: tabMap.size === 0 AND didRegisterTabsRef.current === true AND value !== null → calls commitAutomaticValueChange(null, REASONS.missing) → setValue(null)!

    This resets the value to null. When the promise resolves and React re-renders, no tab is selected, and Panel B doesn't render. The user has to click Tab B again.

    The fix: The sortedMap in CompositeList should not filter out disconnected nodes, since they may be temporarily disconnected due to Suspense. Let me verify this is the right approach:

  45. Assistant

    The isConnected filter in CompositeList was added intentionally. The cleanest fix is in TabsRoot.tsx — when tabMap.size === 0, we should not reset the value. Instead, just return early like the old code did. The "missing tab" case will still be handled by the selectionIsMissing check when tabMap has entries.

  46. Assistant

    Now I can see the issue clearly. Lines 287-294:

    if (tabMap.size === 0) {
      if (!didRegisterTabsRef.current || value === null) {
        return;
      }
      commitAutomaticValueChange(null, REASONS.missing);
      return;
    }
    

    When the Suspense boundary catches and DOM elements become disconnected, CompositeList's sortedMap (which filters by node.isConnected) becomes empty, causing tabMap.size === 0. Since didRegisterTabsRef.current is true and value is "b" (not null), it calls commitAutomaticValueChange(null, REASONS.missing) which resets value to null.

    The fix: When tabMap.size === 0, just return early without resetting the value. The tab elements may be temporarily disconnected due to Suspense:

  47. Assistant

    Good. Now let me verify the change looks correct and run the existing tests:

  48. Assistant

    Good. The function is still defined and used at line 328 for the selectionIsDisabled || selectionIsMissing case. Now let me run the existing tabs tests:

  49. Assistant

    One test failed - it expects the "missing" reason to fire when tabs are removed. Let me look at this test:

  50. Assistant

    Let me look at the failing test around line 958:

  51. Assistant

    Let me revert my change and try a different approach. The failing test shows that when ALL tabs are truly removed (via unmount, not Suspense), the value should be reset. I need a way to distinguish between the two cases.

    Let me think about this differently. The CompositeList has a MutationObserver that watches for DOM changes. When nodes are truly removed (component unmounts), unregister is called which removes the node from the internal map. But when nodes are disconnected due to Suspense, unregister is NOT called - the nodes are still in the map.

    The sortedMap uses .filter((node) => node.isConnected) which filters out disconnected nodes. This is the root cause - it makes tabMap empty even though the tabs are still registered internally.

    The better fix is to NOT filter by isConnected in sortedMap. Instead, only filter when computing the sort order, or don't filter at all (disconnected nodes sort consistently - compareDocumentPosition returns DOCUMENT_POSITION_DISCONNECTED).

  52. Assistant

    Now let me fix the root cause in CompositeList instead. The sortedMap filters by node.isConnected, which incorrectly empties the map when Suspense temporarily disconnects elements:

  53. Assistant

    Now I need to remove the .filter((node) => node.isConnected) from the sortedMap computation. This will prevent tabMap from becoming empty when elements are temporarily disconnected due to Suspense.

    Let me make the change.

  54. Assistant

    Good, the filter is removed. Now let me run the tests to verify the fix:

  55. Assistant

    All 103 tests pass. Let me also run the other tabs-related tests and the CompositeList tests:

  56. Assistant

    All tests pass. Let me also run the composite root tests and a broader set of tests to check for any regressions:

  57. Assistant

    Let me run tests for other components that use CompositeList (Menu, Select, etc.):

  58. Assistant

    All tests pass. Let me verify the change is correct by looking at what we changed:

  59. Assistant

    Let me also update the stale comment:

  60. Assistant

    Good. Let me verify the final diff:

  61. Assistant

    Let me run a broader test to make sure nothing is broken across the entire react package:

  62. Assistant

    All 6259 tests pass (895 skipped). The fix is correct and complete. Let me verify the final state:

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.