Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-sonnet-5· anthropicHugging 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. Claude Assistant

    Let's write a temporary reproduction test script to confirm the bug and understand behavior.

  3. Claude Assistant

    Now add logging to TabsRoot's automatic effect.

  4. Claude Assistant

    Now let's run the repro test (single debug, at the end) with logging enabled.

  5. Claude Assistant

    Good, reverted debug changes. Now let's implement the actual fix.

  6. Claude Assistant

    Now let's implement the fix with the microtask-based deferral for missing-tab detection.

  7. Claude Assistant

    Now let's write the repro test back (clean version) and run it to verify the fix.

  8. Claude Assistant

    The fix works. Now let's remove the temporary repro test file and run the full TabsRoot test suite plus related tests to check for regressions.

  9. Claude Assistant

    All tabs tests pass. Now let's run the full test suite (jsdom) to check for broader regressions, particularly other components using CompositeList since we didn't touch that file, but let's also run internals tests.

  10. Claude Assistant

    All 279 test files pass (6369 tests passed, 895 skipped). Now let's check TypeScript type checking for the changed file.

  11. Claude Assistant

    No TypeScript errors. Let's also run eslint on the modified file.

  12. Claude Assistant

    Let's make all the outer effect's bare return; statements consistent with return undefined; to satisfy the lint rule.

  13. Claude Assistant

    Also need the final implicit return at the end of the function (no explicit return statement) to be consistent — but consistent-return only cares about explicit return statements typically; let's re-run eslint.

  14. Claude Assistant

    Need to add explicit return undefined; at the end of the function too.

  15. Claude Assistant

    Lint passes now. Let's re-run the full tabs test suite and the reproduction test again to make sure everything still works after these edits.

  16. Claude Assistant

    All tests pass. Now remove the temporary repro test file and run the full test suite once more (chromium too, since that's the default test target) to be thorough.

  17. Claude Assistant

    Now let's run the complete test suite once more to make sure nothing broke, and also double check the prettier formatting.

  18. Claude Assistant

    All 6369 tests pass with no regressions. Let's do a final review of the diff and clean up.

  19. Claude Assistant

    Only the intended file is modified, and the temporary reproduction/debug files have been removed. Let's do one final full diff review.

  20. Claude Assistant

    This looks clean and minimal. Let's go through the checklist.

    Checklist Review

    1. If an error was reported in the issue description, I have successfully reproduced it.

  21. Claude Assistant

    Summary of root cause and fix:

    Root cause: PR #4704 added logic to TabsRoot's automatic-fallback useIsoLayoutEffect that treats an empty (or partially empty) tabMap/missing selectedTabMetadata as "tabs were removed from the DOM" and eagerly resets the uncontrolled value to null (or to the first enabled tab). However, when a descendant inside Tabs.Root suspends and the nearest Suspense boundary is outside Tabs.Root, React keeps the previously-committed tree mounted (hidden) and, once the promise resolves, re-establishes its effects as if freshly mounted. This causes the CompositeList used to track Tab/Panel registrations to transiently unregister and re-register all tabs (a real, momentary tabMap.size === 0, or a temporarily-missing entry for the selected value) purely due to this effect-remount churn — not because any tab was actually removed. The effect saw this transient state and permanently committed value = null, and once value was null, the "missing" detection logic no longer fired to correct it back, silently breaking tab selection until a subsequent user-triggered click reset value again.

    Fix: In TabsRoot.tsx, defer the "tabs missing" fallback commits (both the fully-empty-map case and the single-missing-tab case) to a microtask, re-verifying at that point whether the tabs are still missing. Because the transient re-registration churn completes synchronously (within the same commit cascade) before any microtask runs, the effect's cleanup (triggered when tabMap changes again) cancels the pending fallback before it ever executes. Genuine removals (where the tabs really stay gone) still correctly trigger the fallback via the microtask, just one tick later — which existing tests already tolerate since they assert via waitFor. The "disabled tab" fallback path remains synchronous since it isn't subject to this registration churn.

    Verified: reproduced the bug with a temporary test mimicking the issue's Suspense scenario, confirmed it failed before the fix and passed after; ran the full Tabs test suite and the entire jsdom unit test suite (6369 tests) with no regressions; ran tsc and eslint/prettier clean on the changed file.

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