Skip to content
TheChatArchiveThe Chat Archive
GLMz-ai/glm-5.2· 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. GLM Assistant

    Let me start by exploring the repository structure to understand the codebase.

  3. GLM Assistant

    Let me explore the packages directory, particularly the tabs component.

  4. GLM Assistant

    Now let me look at the TabsRoot.tsx and the related context/hooks.

  5. GLM Assistant

    Let me look at the useTransitionStatus and useOpenChangeComplete hooks.

  6. GLM Assistant

    Let me look at the git history and the PR #4704 that's mentioned as the likely cause.

  7. GLM Assistant

    Let me look at the test file to understand testing conventions.

  8. GLM Assistant

    Let me search for any existing suspense-related tests in the codebase to understand the test setup.

  9. GLM Assistant

    Let me reproduce the issue by creating a test script. First, let me understand the renderer setup.

  10. GLM Assistant

    Now let me create a temporary test to reproduce the issue.

  11. GLM Assistant

    I reproduced the issue. The DOM shows Panel A content and "Loading…" together after resolving. Let me investigate the React Suspense behavior more closely. Let me check the v1.4.1 version of the code for comparison.

  12. GLM Assistant

    The TabsPanel is identical. Let me compare TabsRoot between v1.4.1 and current.

  13. GLM Assistant

    Now I can see the key difference. Let me write a more diagnostic test to understand the React Suspense state preservation behavior.

  14. GLM Assistant

    Wait, in my test I made it controlled (value={val} onValueChange={setVal}). But the issue uses uncontrolled (defaultValue). Let me keep it uncontrolled to match the issue, but add logging via the Root wrapper that doesn't make it controlled. Actually, let me reconsider.

    Actually, let me make it uncontrolled to match the issue exactly. Let me remove the controlled part.

  15. GLM Assistant

    Let me get the full DOM structure and understand React's behavior better with diagnostics.

  16. GLM Assistant

    Now I understand the React behavior. The suspended subtree's previous content is kept hidden (display: none) while the fallback shows. Let me test the baseline React behavior with a simple example to understand state reversion.

  17. GLM Assistant

    I have a syntax error (trailing comma in JSX). Let me fix it.

  18. GLM Assistant

    The pure React test shows the state stays "b" but content stays hidden — this is a test artifact with act. But the key difference: in my pure test, the tab state is held by App which is ABOVE the Suspense boundary. In the Tabs case, the value state is held by Tabs.Root which is INSIDE the boundary. Let me test this crucial difference.

  19. GLM Assistant

    The act/suspense flushing is interfering with my tests. Let me check the React version and look at how existing async tests handle this.

  20. GLM Assistant

    React 19.2.5. Let me work around the act warning by suppressing console.error and using longer polling, to see if the bug is genuinely reproducible or a test artifact.

  21. GLM Assistant

    The bug reproduces with Tabs. Now let me verify whether pure React (state inside boundary) works or also fails, to confirm it's a Tabs-specific bug and not a test artifact.

  22. GLM Assistant

    The pure React case also fails in the test environment, suggesting the test env can't flush state-update-triggered suspense retries. Let me verify whether the test env can flush suspense triggered on initial render (like the DialogPortal test).

  23. GLM Assistant

    The test env can flush initial-render suspense but not state-update-triggered suspense. Let me look at the CHANGELOG and search for any related fix or discussion.

  24. GLM Assistant

    Let me check if the test renderer uses fake timers, which could affect suspense retry flushing.

  25. GLM Assistant

    No fake timers. BASE_UI_ANIMATIONS_DISABLED = true. requestAnimationFrame is mapped to setTimeout.

    Let me look at the setupVitest from mui internal-test-utils to see if it sets fake timers.

  26. GLM Assistant

    Let me definitively understand React's behavior by examining the React source code for state updates that cause suspension.

  27. GLM Assistant

    The React source is heavily transformed. Let me take a more direct approach: temporarily revert the #4704 effect changes to confirm they're the cause. Let me first save my repro test, then experiment.

  28. GLM Assistant

    Let me try swapping in the v1.4.1 TabsRoot to confirm #4704 is the cause.

  29. GLM Assistant

    The test env fails for both v1.4.1 and v1.5.0 — confirming it's a test artifact, not the real bug. Let me restore the current TabsRoot and find a different reproduction approach.

  30. GLM Assistant

    Let me check if there are any branches or later commits that might contain the fix.

  31. GLM Assistant

    Let me look at the React source to understand whether state updates that cause suspension are rolled back.

  32. GLM Assistant

    Let me try resolving the promise within the same act as the click, which may let React flush the retry properly.

  33. GLM Assistant

    Very interesting! With same-act resolution, the value became null — both tabs unselected, no panels. This points to #4704's commitAutomaticValueChange(null, REASONS.missing). Let me test v1.4.1's TabsRoot with this same-act scenario to confirm.

  34. GLM Assistant

    Confirmed! v1.4.1 renders Panel B correctly; v1.5.0 sets value to null (both tabs unselected, no panels). I now have a reproducible test. Let me instrument the #4704 effect to see exactly which branch sets value to null.

  35. GLM Assistant

    Let me add temporary instrumentation to the effect to trace which branch fires during the suspense retry.

  36. GLM Assistant

    No python. Let me use the edit command to add instrumentation.

  37. GLM Assistant

    I found the root cause. During the suspense retry, tabMap transiently becomes empty (tabs unregister then re-register), and the tabMap.size === 0 branch fires commitAutomaticValueChange(null, REASONS.missing), setting value to null. v1.4.1 just returned early when tabMap.size === 0. Let me look at the tests #4704 added for the "all tabs removed" behavior.

  38. GLM Assistant

    Let me look at how tabs register/unregister into tabMap to understand the mechanism.

  39. GLM Assistant

    Let me see how setTabMap is wired — the onMapChange callback.

  40. GLM Assistant

    Let me see the full useCompositeListItem to understand the registration lifecycle.

  41. GLM Assistant

    Let me check how setTabMap is wired to the CompositeList and add instrumentation there.

  42. GLM Assistant

    tabMap is the sortedMap (filtered by isConnected). Let me add instrumentation to log when setTabMap is called and with what size, to understand the transient.

  43. GLM Assistant

    This is getting messy. Let me restore and add cleaner instrumentation.

  44. GLM Assistant

    Now let me add a clean log to the onMapChange/setTabMap path. Let me modify the TabsList to log onMapChange, OR wrap setTabMap cleanly. Let me wrap setTabMap in TabsRoot with a stable callback but keep the name.

    Actually, the issue is the context type expects setTabMap of a certain type. Let me just add logging via a wrapped function with the same signature.

  45. GLM Assistant

    Let me add logging to the register/unregister in CompositeList to confirm the unregister mechanism during the retry.

  46. GLM Assistant

    Let me look at how the Dialog suspense issue (#3700) was fixed, as it may provide a pattern.

  47. GLM Assistant

    Let me restore the clean files first, then experiment with fixes.

  48. GLM Assistant

    Let me run the existing TabsRoot tests to establish a baseline.

  49. GLM Assistant

    Let me check if the codebase has visibility-checking utilities, and look at how the rootRef could be accessed.

  50. GLM Assistant

    Let me re-add register/unregister instrumentation and run the genuine "all tabs removed" test to compare isConnected values.

  51. GLM Assistant

    I now have a clear understanding. The root cause: during Suspense, the tab registrations are torn down (effects cleanup) while the tab DOM nodes remain connected (hidden via display:none). The tabMap.size === 0 branch then incorrectly fires commitAutomaticValueChange(null, 'missing').

    The robust fix: when tabMap is empty, check if the previously-registered tab nodes are still connected to the DOM. If they are (Suspense hide), preserve the value; if they're disconnected (genuine removal), fire the null fallback.

    Let me view the current code and implement.

  52. GLM Assistant

    Now let me implement the fix. First, add a ref to track the last known tab DOM nodes:

  53. GLM Assistant

    The fix looks good. Let me run the repro test (same-act scenario) to verify the bug is fixed.

  54. GLM Assistant

    The bug is fixed — Panel B is now rendered. Now let me run the full TabsRoot test suite to ensure I didn't break the "all tabs removed" feature or anything else.

  55. GLM Assistant

    All TabsRoot tests pass. Let me run the broader tabs test suite (panel, tab, list, indicator).

  56. GLM Assistant

    All tabs tests pass. Let me also test the exact issue scenario (click, wait for Loading, resolve, check Panel B) to see if my fix also helps there.

  57. GLM Assistant

    Let me see the full DOM to understand the state in this scenario.

  58. GLM Assistant

    The "click -> loading -> resolve" flow fails due to the test env's inability to flush state-update-triggered suspense retries (a test artifact affecting even pure React, as I confirmed earlier). The same-act scenario — which properly flushes — passes with my fix, faithfully reproducing the bug mechanism (the null fallback firing during the Suspense hide).

    Let me verify there's no leftover instrumentation in TabsRoot and confirm the diff is clean.

  59. GLM Assistant

    Clean diff — only TabsRoot.tsx changed (19 insertions), no instrumentation left. Let me view the final diff.

  60. GLM Assistant

    My fix is validated. The "click -> loading -> resolve" flow fails only due to the test env's act-rollback for unawaited state-update-triggered suspensions (which I confirmed affects even pure React). The same-act scenario — which faithfully flushes and reproduces the bug mechanism — passes.

    Now let me remove my temporary repro test (per instructions, I must not add tests) and run the full tabs suite once more to confirm everything passes.

  61. GLM Assistant

    All tabs tests pass. Let me specifically run the #4704 feature tests to confirm the automatic-selection behavior is fully preserved.

  62. GLM Assistant

    All 23 onValueChange tests pass — the #4704 feature is fully preserved. Let me run a TypeScript check to ensure no type errors.

  63. GLM Assistant

    These TS6305 errors are pre-existing build-artifact issues unrelated to my change. Let me check specifically for errors in the tabs files and get the real tsc exit code.

  64. GLM Assistant

    No non-TS6305 errors — my change is type-correct (TS6305 are pre-existing stale-build artifacts). Let me verify the tabMap key type to make sure my Set<Element> declaration matches, to be safe.

  65. GLM Assistant

    The types are fine (tsc confirmed no errors; Map/Set methods are bivariant). For precision and consistency with tabMap's declared Map<Node, ...> key type, let me use Set<Node> instead of Set<Element>.

  66. GLM Assistant

    The replace is the editor command operating on the open file. Let me use it correctly.

  67. GLM Assistant

    Now let me re-add the temporary repro test to confirm the fix still works after the type refinement, run it, then remove it and run the full tabs suite.

  68. GLM Assistant

    Everything passes. Let me remove the temporary repro test and verify the final state.

  69. GLM Assistant

    The diff is clean. Let me run the linter on the modified file to ensure no lint issues.

  70. GLM Assistant

    No lint errors. Let me verify prettier formatting on the file.

  71. GLM Assistant

    Prettier found formatting issues. Let me see the diff prettier would make, then apply it.

  72. GLM Assistant

    Prettier reformatted the .some() callback to one line. Let me verify the final diff and run the tests once more.

  73. GLM Assistant

    The diff is clean and prettier-formatted. Let me run the full tabs test suite one final time to confirm everything passes.

  74. GLM Assistant

    All tests pass, ESLint clean, Prettier formatted. Let me do a final check for any leftover temporary files and confirm the final state.

  75. GLM Assistant

    The state is clean — only TabsRoot.tsx is modified, no leftover temp files. Let me do a final review of the complete modified effect.

  76. GLM Assistant

    The fix is complete and correct. Let me do one final full run of the tabs suite to confirm stability, plus a quick run of the composite list tests (since tabs depend on them) to be thorough.

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