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 check what kind of project this is.

  3. Assistant

    This looks like a monorepo with lerna/pnpm. Let's look at the root package.json to understand the project better.

  4. Assistant

    Let me look at the packages directory to find the tabs component.

  5. Assistant

    Let me explore the structure more.

  6. Assistant

    Let's look at the tabs directory.

  7. Assistant

    Let me explore the tabs component structure more deeply.

  8. Assistant

    Let me examine the issue. The bug was introduced in v1.5.0, and it's related to tabs panel content not rendering when a child component suspends without a boundary within Tabs.Root. The issue mentions PR #4704 as a potential cause. Let me look at the tab panel implementation and the tab root implementation.

  9. Assistant

    Now let me look at the root component to understand the structure better.---

  10. Assistant

    Let me look at one file at a time.

  11. Assistant

    Now let me look at the useTransitionStatus hook and the referenced PR #4704.

  12. Assistant

    Let me analyze the issue. The problem is that when a child component of Tabs.Panel suspends (throws a Promise) and the Suspense boundary is outside of Tabs.Root, the panel content is not rendered on first click.

    The issue mentions PR #4704 as a potential cause. Let me look at the git history to understand what changed.

    The key issue is in useTransitionStatus. When open is true (a tab panel is selected), but a child suspends and causes the whole Tabs.Root to unmount and remount (because the Suspense boundary is above), the useTransitionStatus hook might not correctly handle this scenario.

    Wait, actually let me re-read the issue more carefully. The issue is:

    1. The Suspense boundary is outside Tabs.Root
    2. A tab panel has a child that suspends
    3. When clicking the tab for the first time, the panel content is not rendered
    4. Only when clicking the trigger a second time, the panel is rendered

    This means the Tabs.Root doesn't unmount per se. The Suspense boundary catches the thrown Promise from the child component and shows the fallback. But the Tabs.Root itself stays mounted. When the Promise resolves, the Suspense boundary re-renders its children, and the tab panel should now render properly.

    Wait, but if the Suspense boundary is OUTSIDE Tabs.Root, then when the child suspends, the entire Tabs.Root would be replaced by the Suspense fallback. Then when the promise resolves, the entire Tabs.Root is re-created, which means the state (including which tab is selected) would be reset.

    But the issue says this worked in v1.4.1, so something must have changed.

    Let me think about this differently. With the Suspense boundary outside Tabs.Root:

    1. Initially, tab "a" is selected (defaultValue="a"), panel A renders fine
    2. User clicks tab "b", the value changes to "b"
    3. Panel B tries to render, its child (SuspendingChild) throws a Promise
    4. The Suspense boundary catches it, replaces everything with "Loading..."
    5. After 500ms, the Promise resolves, the Suspense boundary re-renders its children
    6. Tabs.Root is recreated with defaultValue="a", so tab "a" is selected again... wait, that's not right either.

    Actually wait. If the entire Tabs.Root is unmounted and remounted by Suspense, the defaultValue would be used again. So when the promise resolves, the tabs would show tab A again, not tab B. But the user was clicking tab B...

    Hmm, but the issue says "panel content is not rendered when opening a tab for the first time" and "Only when clicking the trigger a second time, the panel is rendered." This suggests that when the Suspense boundary resolves, the tab B trigger is still in the "selected" visual state, but the panel doesn't render.

    Actually, let me re-think. In React Suspense, when a component suspends:

    • The nearest Suspense boundary catches it and shows the fallback
    • When the promise resolves, React re-renders from the Suspense boundary
    • The component tree is recreated from scratch (new instances)

    But wait, I need to consider that in React 18/19, Suspense doesn't cause the component to unmount and remount - it's more nuanced. When a child suspends, the Suspense boundary replaces its children with the fallback. But when the promise resolves, React re-renders the original children. The key question is whether React maintains the state of components above the suspended child.

    Actually, the way Suspense works:

    • The component that suspends throws a Promise
    • React bubbles up to the nearest Suspense boundary
    • The Suspense boundary's children are replaced with the fallback
    • When the Promise resolves, React re-renders from the Suspense boundary
    • The component tree under the Suspense boundary is re-rendered (not necessarily remounted)

    But in this case, the Suspense boundary is ABOVE Tabs.Root. So when the child of panel B suspends:

    1. The Promise propagates up to the Suspense boundary
    2. The entire Tabs.Root (which is inside the Suspense boundary) is replaced with the fallback
    3. This means ALL state in Tabs.Root (and its children) is lost
    4. When the promise resolves, the Suspense boundary re-renders, and Tabs.Root is created from scratch
    5. Tabs.Root uses defaultValue="a", so tab A is selected
    6. Panel A renders, panel B does not (because it's not selected)

    So the user would need to click tab B again, and this time the SuspendingChild would not throw (since the promise already resolved). So it would work the second time.

    Wait, but the dataPromise is defined outside the component as a module-level constant. So it's the same Promise every time. The use() hook with a resolved promise should just return the resolved value immediately.

    Actually, in React 19, use() on a resolved promise returns the value immediately. But in the first render after Suspense resolves, the Promise is already resolved, so use() should work fine.

    Hmm, let me reconsider. The issue might be more subtle. Let me look at useTransitionStatus more carefully.

    When the Tabs.Root is re-created after Suspense resolves:

    1. TabsPanel for value "b" is created with open = false (because selectedValue is "a" from defaultValue)
    2. In useTransitionStatus(open=false), mounted starts as false, transitionStatus starts as undefined
    3. Panel B doesn't render (shouldRender = keepMounted || mounted = false || false = false)

    Then when user clicks tab B:

    1. value changes to "b"
    2. Panel B has open = true
    3. In useTransitionStatus, open && !mounted -> setMounted(true); setTransitionStatus('starting')
    4. shouldRender = true
    5. But now the child suspends again? No, the promise is already resolved...

    Wait, actually the issue might be that when the Suspense boundary resolves and re-renders Tabs.Root, React might throw again because the promise might not be fully resolved yet, or there's some timing issue.

    Actually, I think the real issue might be different. Let me re-read the issue more carefully.

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

    OK so the scenario is:

    1. User clicks tab B
    2. Tab B's panel tries to render, child suspends
    3. Suspense boundary catches it, Tabs.Root is unmounted, fallback shown
    4. Promise resolves, Suspense re-renders
    5. Tabs.Root re-creates with defaultValue="a", but... wait, if the value was controlled or something?

    Actually, let me re-read the repro code:

    <Tabs.Root defaultValue="a">
    

    So this is uncontrolled. When the component re-mounts after Suspense, defaultValue is "a". Tab A would be selected.

    But the user was clicking tab B! So from the user's perspective, they click tab B, see "Loading...", then when it resolves they see tab A again. That's weird but might be "correct" behavior since it's uncontrolled.

    But the issue says "the panel content is not rendered when opening a tab for the first time". I think the scenario is:

    1. Click tab B -> panel content is not rendered (Suspense catches)
    2. Suspense resolves, tabs are re-created, tab A is selected
    3. Click tab B again -> now the promise is resolved, so no suspense, panel B renders

    So the "first time" means the first time after the component mounts. If the user clicks tab B again, it works because the promise is already resolved.

    Hmm, but the issue says "Only when clicking the trigger a second time, the panel is rendered." This seems to suggest that after the Suspense resolves, clicking the trigger again works. That matches what I described.

    But is this a bug in the Tabs component or just expected behavior with Suspense? The issue says it worked in v1.4.1 but not in v1.5.0.

    Let me check what changed in PR #4704. Let me look at the git log.

  13. Assistant

    Let me look at PR #4704 and the recent tabs fix commit.

  14. Assistant

    Let me look at the tabs fix commit that's already in the repo.

  15. Assistant

    Let me see what changes were made in the recent tabs fix.

  16. Assistant

    Let me look at the PR #4704 changes and the useTransitionStatus hook.

  17. Assistant

    Let me look at the useTransitionStatus hook and think about the issue. The problem is when a child suspends and the Suspense boundary is outside Tabs.Root.

  18. Assistant

    Let me look at the useTransitionStatus hook and understand the issue better.

  19. Assistant

    Now let me understand the issue. Let me trace through the flow when a child component suspends inside a Tabs.Panel. First, let me look at the useOpenChangeComplete hook used in TabsPanel.

  20. Assistant

    Let me find the file.

  21. Assistant

    Let me look at the useOpenChangeComplete hook and understand the flow when a child suspends inside a panel.

  22. Assistant

    Let me look at the PR #4704 changes more carefully and check what version tags are available.

  23. Assistant

    Let me understand the flow better. Let me look at how tabs register and what happens with Suspense. Let me look at the useCompositeListItem hook.

  24. Assistant

    Let me look at the actual issue. The problem is:

    1. Tabs.Panel uses useTransitionStatus(open) where open is true when the panel is selected

    2. useTransitionStatus has render-time state updates that set mounted = true when open becomes true

    3. When a child of the panel suspends, React needs to handle thisLet me trace through the exact sequence of events:

    4. User clicks Tab B → value changes to "b"

    5. Panel B starts rendering with open = true

    6. In useTransitionStatus(true):

      • mounted is false (initial state)
      • The render-time check: if (open && !mounted) → setMounted(true), setTransitionStatus('starting')
      • React re-renders with mounted = true
    7. Now shouldRender = true, so the panel renders its children

    8. SuspendingChild calls use(dataPromise) which throws the promise

    9. React catches the promise and goes up to the Suspense boundary (outside Tabs.Root)

    10. The Suspense boundary renders its fallback

    Now here's the key question: what state does React preserve for the Tabs components?

    In React, when Suspense catches a thrown promise during a render:

    • If this is the initial render, the component is not mounted yet
    • If this is a re-render (update), the existing committed state is preserved

    But wait - in step3, we had a render-time state update (setMounted(true)). This is a "discrete" update during render. React processes it synchronously.

    Actually, let me reconsider. The issue might be more subtle. Let me look at the useTransitionStatus hook more carefully.

    The render-time state updates in useTransitionStatus are:

    if (open && !mounted) {
        setMounted(true);
        setTransitionStatus('starting');
    }
    

    This is called during render. In React, calling setState during render is a "state reducer" pattern - React will immediately re-render the component with the new state before continuing.

    So when Panel B's open becomes true:

    1. First render: mounted = false, open = true → setMounted(true), setTransitionStatus('starting')
    2. React immediately re-renders with mounted = true, transitionStatus = 'starting'
    3. shouldRender = true, so children are rendered
    4. SuspendingChild suspends
    5. React catches the promise at the Suspense boundary

    Now, here's the crucial part: when the Suspense boundary catches this and renders its fallback, what happens to the Tabs component tree?

    When the Suspense boundary replaces its children with the fallback, the children are effectively unmounted. All their state is lost. When the promise resolves, React re-renders the Suspense boundary's children, which creates fresh component instances.

    So when the promise resolves:

    • Tabs.Root re-mounts fresh with defaultValue = "a"
    • Tab A is selected
    • Panel B has open = false, mounted = false
    • User needs to click Tab B again

    But wait, the issue says clicking Tab B the second time also doesn't work initially. Let me re-read:

    "Only when clicking the trigger a second time, the panel is rendered."

    Hmm, so:

    1. First click on Tab B → child suspends → Suspense catches → "Loading..." → promise resolves → Tabs remount with Tab A
    2. Click Tab B again → should work now because promise is already resolved

    But the issue says the panel content is NOT rendered when opening a tab for the first time, and only renders on the second click.

    Wait, maybe I'm misunderstanding. Let me re-read the issue more carefully.

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

    I think what's happening is:

    1. The Suspense boundary catches the promise
    2. When the promise resolves, React re-renders
    3. But something goes wrong with the Tabs state/rendering
    4. The panel doesn't show content
    5. Clicking the trigger again makes it work

    Let me think about what could cause this...

    Actually, looking at the code more carefully, I see that useTransitionStatus uses render-time state updates:

    if (open && !mounted) {
        setMounted(true);
        setTransitionStatus('starting');
    }
    

    And also:

    if (!open && mounted && transitionStatus !== 'ending' && !deferEndingState) {
        setTransitionStatus('ending');
    }
    

    These are render-time state updates. In React, when a component suspends (throws a promise), React will NOT commit the render. So the state updates from this render are lost.

    But wait, setMounted(true) was already called during render as a state reducer. In React 19 (which uses use()), state reducers during render are handled differently than regular setState calls.

    Actually, I think the issue is more specific. Let me look at the interaction between useTransitionStatus and the Suspense boundary.

    When the Suspense boundary catches the promise and then resolves, React re-renders from the Suspense boundary. The Tabs component tree is recreated. But here's the thing: useTransitionStatus has this code:

    const [mounted, setMounted] = React.useState(open);
    

    When open is true on the first render after remount:

    • mounted starts as true (from useState(open))
    • But wait, the panel's open might be false initially (Tab A is selected)
    • Then when Tab B is clicked, open becomes true
    • mounted is false (from useState(false))
    • if (open && !mounted) → setMounted(true), setTransitionStatus('starting')
    • React re-renders, children render, child suspends again? No, the promise is already resolved...

    Wait, the promise is a module-level constant, so it's the same promise every time. After it resolves, use(dataPromise) should return the resolved value immediately.

    So when the user clicks Tab B the second time (after the Suspense resolved and remounted):

    1. open becomes true
    2. useTransitionStatus: mounted = false, open = true → setMounted(true), setTransitionStatus('starting')
    3. React re-renders with mounted = true
    4. shouldRender = true
    5. Children render, use(dataPromise) returns the resolved value
    6. Panel B content should render

    This should work! So why doesn't it?

    Let me look at the useOpenChangeComplete hook more carefully:

    useOpenChangeComplete({
        open,
        ref: panelRef,
        onComplete() {
          if (!open) {
            setMounted(false);
          }
        },
    });
    

    When open changes to true, useOpenChangeComplete waits for animations to complete and then calls onComplete. But onComplete only sets mounted = false when open is false. So when open is true, this is a no-op.

    But wait, the useOpenChangeComplete hook uses a useEffect with open as a dependency:

    React.useEffect(() => {
        if (!enabled) {
          return undefined;
        }
        const abortController = new AbortController();
        runOnceAnimationsFinish(onComplete, abortController.signal);
        return () => {
          abortController.abort();
        };
    }, [enabled, open, onComplete, runOnceAnimationsFinish]);
    

    When the component unmounts (due to Suspense), the effect cleanup runs and aborts. When it remounts and open is true, the effect runs again and waits for animations. This seems fine.

    Hmm, let me think about this differently. Maybe the issue is related to how React handles the setMounted(true) call during render when there's a Suspense boundary above.

    Actually, I think I might have been overthinking this. Let me look at what happens more carefully with React Suspense.

    When a component throws a promise during render:

    1. React walks up the fiber tree to find the nearest Suspense boundary
    2. React renders the fallback
    3. The suspended subtree is NOT committed
    4. When the promise resolves, React re-renders the suspended component

    But the key question is: are the render-time state updates (setMounted(true)) committed or not?

    In React 19 with use():

    • State updates during render (like setMounted(true) in the if (open && !mounted) check) are processed as "state reducer" calls
    • These are handled synchronously during render
    • If a child suspends AFTER these state updates, the parent's state should be updated- But the Suspense boundary will catch the promise and show the fallback
    • When the promise resolves, React re-renders from the Suspense boundary

    Wait, I think the issue might be that when the Suspense boundary catches the promise, the component tree below it is replaced with the fallback. This means the Tabs components are unmounted. When the promise resolves, they're re-created fresh.

    If they're re-created fresh:

    • Tabs.Root starts with defaultValue = "a" → value = "a"
    • Panel B has open = false, mounted = false
    • User clicks Tab B again → open = true, mounted = false
    • setMounted(true) → React re-renders → mounted = true
    • Children render, promise already resolved → content showsThis should work! Unless there's something else going on.

    Let me look at the PR #4704 changes one more time. Actually, let me check if there's something about the commitAutomaticValueChange that might interfere.

    In TabsRoot, there's this effect:

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

    When the Suspense boundary catches and remounts, didRegisterTabsRef.current is false (ref is fresh). So when tabMap.size === 0 initially, it returns early. Then tabs register, tabMap grows, and didRegisterTabsRef.current is set to true.

    Hmm, this seems fine.

    Wait, I want to look at something else. The useTransitionStatus hook:

    if (open && !mounted) {
        setMounted(true);
        setTransitionStatus('starting');
    }
    

    This is a render-time state update. In React, when you call setState during render, React will re-render the component with the new state before continuing to render children. This is called a "state reducer" pattern.

    But here's the issue: when a child suspends, React needs to throw the promise up to the Suspense boundary. In the process, the render-time state updates might be handled differently.

    Actually, I think I need to test this. Let me create a simple reproduction and see what happens.

    But wait, let me first look at what version of React is being used in this repository.

  25. Assistant

    Let me look at the git history for the useTransitionStatus hook and the PR #4704 changes more carefully.

  26. Assistant

    Let me understand the issue better. Let me look at the git history for the relevant files and try to reproduce the issue.

  27. Assistant

    Let me focus on understanding the issue by looking at what PR #4704 changed in the critical path and also the CompositeList.

  28. Assistant

    Let me look at how tabs register themselves.

  29. Assistant

    Now let me understand the full issue. Let me look at the useAnimationsFinished hook and the useTransitionStatus hook in more detail.

  30. Assistant

    Let me trace through the issue. I need to understand what happens when a child suspends inside a Tabs.Panel with the Suspense boundary outside Tabs.Root. Let me examine the key flow more carefully.

  31. Assistant

    Let me look at how setTabMap is called and trace through the issue step by step. The key insight is that when a child suspends inside Tabs.Panel and the Suspense boundary is outside Tabs.Root, React may handle the render-phase state updates in useTransitionStatus differently. Let me first reproduce the issue.

  32. Assistant

    Let me look at the Tabs list component to understand the tab registration flow:

  33. Assistant

    Now I'm understanding the issue. Let me trace through the flow:

    1. User clicks Tab B → setValue("b") → Panel B renders with open=true
    2. useTransitionStatus(true) sets mounted=true during render
    3. Panel renders children → SuspendingChild suspends (throws Promise)
    4. React catches at Suspense boundary outside Tabs.Root → shows fallback
    5. When Promise resolves → React re-renders from Suspense boundary

    The key question is what happens to tabMap state after the Suspense resolves. The PR #4704 added logic that calls commitAutomaticValueChange(null, REASONS.missing) when tabMap.size === 0 and didRegisterTabsRef.current === true and value !== null.

    Let me create a reproduction script and verify:

  34. Assistant

    Let me look at the existing tests for tabs and find the test setup:

  35. Assistant

    Let me look at the existing tests to understand the testing setup.

  36. Assistant

    Now I need to understand the actual issue. Let me trace through what happens step by step when a child suspends inside Tabs.Panel. Let me look at the useTransitionStatus hook and how the Suspense boundary interacts with it.

    The key issue is in useTransitionStatus - it has render-phase state updates (setMounted(true)) that happen during render. When a child component suspends after this state update, React needs to handle the interruption. Let me look at the useTransitionStatus hook and how it interacts with Suspense.

  37. Assistant

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

    1. Click Tab B → value = "b" → Panel B open = true
    2. useTransitionStatus(true): setMounted(true) during render → shouldRender = true
    3. Panel renders children → SuspendingChild calls use(dataPromise) → suspends
    4. React catches at Suspense boundary (outside Tabs.Root)
    5. Tab effects cleanup → unregister → tabMap becomes empty
    6. Layout effect in TabsRoot: tabMap.size === 0, didRegisterTabsRef.current = true, value = "b" → commitAutomaticValueChange(null, REASONS.missing) → value set to null!
    7. When promise resolves, tabs re-register, but value is already null → no panel selected

    The PR #4704 added this tabMap.size === 0 → commitAutomaticValueChange(null, ...) logic. Let me verify this by looking at the code and creating a fix.

  38. Assistant

    Now I understand the issue. When the Suspense boundary catches and the tab effects clean up, tabMap becomes empty. The layout effect in TabsRoot then calls commitAutomaticValueChange(null, REASONS.missing) which sets value to null. When the promise resolves, the value is already null so no panel is selected.

    Let me fix this:

  39. Assistant

    Now I have a clear picture of the issue. Let me trace the exact flow:

    1. User clicks Tab B → setValue("b") → Panel B open = true
    2. useTransitionStatus(true): setMounted(true) during render → shouldRender = true
    3. Panel renders children → SuspendingChild calls use(dataPromise) → suspends
    4. React catches at the Suspense boundary (outside Tabs.Root) → shows fallback

    Now here's the key: when the child suspends AFTER setMounted(true) was called during render, React catches the suspension at the Suspense boundary. The setMounted(true) was a render-phase state update. React will roll back this render since the tree didn't fully commit (the suspension interrupted it).

    When the promise resolves, React re-renders. But the key question is what happens to mounted.

    Let me write a test to confirm the issue and trace it:

  40. Assistant

    Let me look at the actual issue more carefully by examining the PR #4704 changes and the useTransitionStatus behavior with Suspense.

  41. Assistant

    Let me look at the test for the "missing" tab scenario added by PR #4704:

  42. Assistant

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

    1. User clicks Tab B → value="b" → Panel B has open=true
    2. useTransitionStatus(true) → setMounted(true) during render → shouldRender=true
    3. Panel renders children → SuspendingChild calls use(dataPromise) → suspends
    4. React catches at Suspense boundary (outside Tabs.Root) → shows fallback
    5. DOM elements get disconnected → CompositeList's MutationObserver fires → sortedMap recomputed with .filter((node) => node.isConnected) → empty!
    6. setTabMap({}) called → tabMap.size === 0
    7. TabsRoot layout effect: tabMap.size === 0 && didRegisterTabsRef.current && value !== null → commitAutomaticValueChange(null, REASONS.missing) → value set to null!
    8. Promise resolves → Suspense re-renders → but value is now null → no panel shows
    9. User clicks Tab B again → value="b" → panel renders (promise already resolved)

    The fix should be in the CompositeList - don't filter disconnected nodes from sortedMap. This way tabMap won't become empty when Suspense disconnects DOM nodes temporarily.

  43. Assistant

    Let me look at the CompositeList's isConnected filter more carefully. When the Suspense boundary catches and removes DOM nodes, the isConnected filter causes sortedMap to become empty, which triggers the automatic value change to null in TabsRoot. Let me fix this.

  44. Assistant

    Let me look at the CompositeList code more carefully. I can see the issue: when the Suspense boundary catches, DOM nodes are disconnected, and the isConnected filter causes sortedMap to become empty, which triggers the commitAutomaticValueChange(null) in TabsRoot.

    Let me check what the full sortedMap computation looks like and also the useIsoLayoutEffect that calls onMapChange:

  45. Assistant

    Now I have a clear picture. The issue is in the CompositeList's sortedMap computation which filters nodes by node.isConnected. When the Suspense boundary catches and removes the DOM, the nodes become disconnected, causing sortedMap to become empty. This triggers setTabMap(new Map()) in TabsRoot, and then the layout effect commitAutomaticValueChange(null) sets value to null.

    Let me look at the sortByDocumentPosition function:

  46. Assistant

    Let me look at the sortByDocumentPosition function:

  47. Assistant

    Let me look at how tabMap gets populated and what happens during Suspense:

  48. Assistant

    Now I understand the issue! Let me trace through the exact problem:

    1. When a child inside Tabs.Panel suspends, the Suspense boundary (outside Tabs.Root) catches it
    2. When the Suspense boundary catches, DOM nodes get disconnected
    3. The CompositeList's sortedMap filters out disconnected nodes via isConnected → becomes empty
    4. This triggers setTabMap(new Map()) in TabsRoot → tabMap.size === 0
    5. The layout effect in TabsRoot sees tabMap.size === 0 and didRegisterTabsRef.current === true and value !== null → calls commitAutomaticValueChange(null, REASONS.missing) → sets value to null!
    6. When the promise resolves, value is already null, so no panel is selected

    The fix: In TabsRoot, when tabMap.size === 0 but tabs were previously registered, we should NOT immediately commit a null value change. We should wait to see if the tabs come back (which they do when Suspense resolves).

  49. Assistant

    Now I have a clear understanding. The root cause is: when the Suspense boundary catches, DOM nodes get disconnected, and the CompositeList filters them out via isConnected, causing tabMap to become empty. Then the layout effect in TabsRoot commits value = null.

    The best fix is in the CompositeList - don't filter out disconnected nodes from sortedMap. Instead, sort them to the end. This way tabMap won't become empty during Suspense.

  50. Assistant

    Now I understand the issue. The root cause is in CompositeList - when the Suspense boundary catches, DOM nodes become disconnected. The isConnected filter removes them from sortedMap, making it empty. This triggers setTabMap({}) in TabsRoot, which then triggers the layout effect to call commitAutomaticValueChange(null, REASONS.missing), setting value to null. When the promise resolves, value is already null so no panel renders.

    The fix should be in CompositeList - don't filter disconnected nodes out of sortedMap. Instead, sort them to the end:

  51. Assistant

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

    1. User clicks Tab B → value = "b" → Panel B renders with open = true
    2. useTransitionStatus(true) sets mounted = true → Panel renders children
    3. SuspendingChild suspends → Suspense catches at boundary outside Tabs.Root
    4. Suspense renders fallback → DOM nodes are disconnected
    5. CompositeList's MutationObserver fires → sortedMap recomputed with isConnected filter → empty!
    6. onMapChange(emptyMap) → setTabMap(new Map()) in TabsRoot → tabMap.size === 0
    7. Layout effect: tabMap.size === 0, didRegisterTabsRef.current = true, value = "b" → commitAutomaticValueChange(null, REASONS.missing) → value set to null!
    8. Promise resolves → React re-renders → but value is now null → no panel selected
    9. User clicks Tab B again → value = "b" → panel renders (promise already resolved)

    The fix: In CompositeList, don't filter disconnected nodes out of sortedMap. Instead, sort them to the end. This prevents tabMap from becoming empty during Suspense.

  52. Assistant

    Now let me check the MutationObserver code - it observes node.parentElement, which would be null for disconnected nodes. The existing code already handles this with if (node.parentElement):

  53. Assistant

    Good, the MutationObserver already handles disconnected nodes with if (node.parentElement). Now let me verify the fix works by running the existing tests:

  54. Assistant

    All tests pass. Let me also run any tests for the composite list component:

  55. Assistant

    Let me run the CompositeList tests to make sure they pass too.

  56. Assistant

    Now let me write a test to verify the fix for the specific issue:

  57. Assistant

    All 186 tests pass. Let me also run a broader set of tests that might be affected by the CompositeList change:

  58. Assistant

    All 1119 tests pass. Let me also run the full composite-related tests to make sure nothing is broken:

  59. Assistant

    All tests pass. Let me verify the final state of my fix:

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