Skip to content

[toolbar] Fix disabled state and roving focus bugs - #4968

Merged
atomiks merged 6 commits into
mui:masterfrom
atomiks:codex/toolbar-sweep
Jun 10, 2026
Merged

atomiks merged 6 commits into
mui:masterfrom
atomiks:codex/toolbar-sweep

Conversation

@atomiks

@atomiks atomiks commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

This is part of the Codex sweep for Toolbar. It fixes disabled-state and keyboard-navigation bugs found during review and adds focused regression coverage.

Changes

  • Removed the redundant stopEvent keydown handler from Toolbar.Input that trapped Tab and blocked vertical roving focus when disabled; useFocusableWhenDisabled already prevents text entry without stopping propagation.
  • Computed Toolbar.Root's disabledIndices from each item's actual disabled state, fixed the truthy index-0 check, and carried the disabled state in item metadata for Toolbar.Button, Toolbar.Input, Toolbar.Link, and direct ToggleGroup > Toggle children, so runtime disabled changes stay in sync.
  • Moved the composite's default tab stop off a disabled, non-focusable first item when disabledIndices resolves a render after the initial map population, so the toolbar stays keyboard-reachable.
  • Propagated Toolbar.Group disabled into a direct ToggleGroup child so its toggles disable along with the group.
  • Corrected the Toolbar.Separator data-attribute description and the misleading inherited orientation default; the separator is perpendicular to the toolbar, not always horizontal.

Original findings addressed

  • [P1] Disabled Toolbar.Input trapped focus and blocked vertical roving.
  • [P1] Toolbar.Root miscomputed disabledIndices (index-0 missed, enabled non-focusable items skipped, raw Toggle children treated as disabled).
  • [P2] Composite's initial tab stop left a disabled, non-focusable first item as the toolbar's only tabIndex=0 entry.
  • [P2] Toolbar.Group disabled did not disable a direct ToggleGroup child.
  • [P3] Toolbar.Separator API docs showed the misleading inherited default horizontal and described data-orientation as the toolbar's orientation.

@atomiks atomiks added docs Improvements or additions to the documentation. type: bug It doesn't behave as expected. accessibility a11y component: toolbar Changes related to the toolbar component. component: toggle group Changes related to the toggle group component. labels Jun 3, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 3, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4968
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4968
    

commit: 37b8d91

@code-infra-dashboard

code-infra-dashboard Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+231B(+0.05%) 🔺+58B(+0.04%)

Details of bundle changes

Performance

Total duration: 1,080.82 ms -219.37 ms(-16.9%) | Renders: 50 (+0) | Paint: 1,606.15 ms -353.75 ms(-18.0%)

Test Duration Renders
Slider mount (300 instances) 146.75 ms ▼-56.04 ms(-27.6%) 3 (+0)
Menu mount (300 instances) 112.22 ms ▼-43.74 ms(-28.0%) 2 (+0)
Select open (500 options) 45.62 ms ▼-19.65 ms(-30.1%) 14 (+0)
Menu open (500 items) 58.78 ms ▼-16.98 ms(-22.4%) 12 (+0)

8 tests within noise — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jun 3, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 37b8d91
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a28f77f0c9aad0008b0538b
😎 Deploy Preview https://deploy-preview-4968--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks marked this pull request as ready for review June 8, 2026 03:38

atomiks commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Code Review (GPT-5.5)

Approve ✅ The branch fixes the Toolbar disabled/focus regressions at the metadata source, and the added tests fail on freshly fetched upstream/master but pass on the PR head.

1. Bugs / Issues (None)

No branch-relevant bugs, repo-convention issues, or documentation mismatches found in the full upstream/master...upstream/pr/4968 diff.

Root Cause & Patch Assessment

The fix addresses the underlying metadata problem rather than only the observed keyboard symptoms: Toolbar items now report both disabled and focusableWhenDisabled, direct ToggleGroup > Toggle items register disabled state with the outer Toolbar composite, and Toolbar.Group disabled now flows into direct toggle groups.

The shared useCompositeRoot fallback is narrowly scoped to explicit disabledIndices, so it covers Toolbar’s late metadata update without changing composites that rely on DOM disabled fallback behavior.

Test Coverage Assessment

Validation run on the PR head:

  • pnpm test:jsdom Toolbar --no-watch passed.
  • pnpm test:chromium Toolbar --no-watch passed.
  • pnpm test:jsdom CompositeRoot --no-watch passed.
  • pnpm typescript passed.
  • pnpm eslint passed.
  • git diff --check upstream/master...upstream/pr/4968 passed.

I also applied the new Toolbar regression tests onto freshly fetched upstream/master; they failed there as expected, including the direct ToggleGroup > Toggle, disabled input, initial tab stop, and runtime-disabled toggle cases. That gives good confidence the tests are guarding the intended regressions rather than only asserting the new implementation.

@atomiks
atomiks merged commit cf6b25a into mui:master Jun 10, 2026
6 checks passed
@atomiks
atomiks deleted the codex/toolbar-sweep branch June 10, 2026 05:39
@michaldudak michaldudak mentioned this pull request Jun 17, 2026
@michaldudak michaldudak removed the docs Improvements or additions to the documentation. label Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility a11y component: toggle group Changes related to the toggle group component. component: toolbar Changes related to the toolbar component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants