Skip to content

[accordion][collapsible] Apply the native disabled attribute to triggers - #5607

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:claude/base-ui-issue-4114-ad52f1
Sep 17, 2026
Merged

atomiks merged 3 commits into
mui:masterfrom
atomiks:claude/base-ui-issue-4114-ad52f1

Conversation

@atomiks

@atomiks atomiks commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4114

Disabled Accordion and Collapsible triggers rendered aria-disabled and stayed in the tab order. The focusableWhenDisabled: true hardcode is a leftover from Accordion's composite days (arrow-key navigation was removed in #4965), so the triggers now match Button and the other plain triggers: when disabled, native triggers render the disabled attribute, while non-native triggers keep aria-disabled="true" and receive tabindex="-1".

Changes

  • Removed the hardcoded focusableWhenDisabled: true from Accordion.Trigger and Collapsible.Trigger.
  • Added regression coverage for native disabled attributes and non-native aria-disabled / tabindex attributes and Tab behavior; updated the disabled-trigger focus expectation.

Changelog note

This changes observable output without touching any documented API: disabled triggers leave the tab order. For native triggers, aria-disabled is replaced by disabled, so [aria-disabled] CSS selectors stop matching. Non-native triggers keep aria-disabled="true" and receive tabindex="-1", without a disabled attribute. The documented styling hook data-disabled is unchanged, so this stays within the semver contract, but the changelog should call it out. In particular, the render={<Button />} workaround posted in #4114 must be removed after upgrading: it computes disabled from props['aria-disabled'], which is no longer set, so leaving it in place renders an enabled-looking (though still inert) button.

@atomiks atomiks added type: bug It doesn't behave as expected. component: collapsible Changes related to the collapsible component. component: accordion Changes related to the accordion component. labels Sep 1, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 1, 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@5607
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5607
    

commit: b8bd647

@code-infra-dashboard

code-infra-dashboard Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react ▼-50B(-0.01%) ▼-9B(-0.01%)

Details of bundle changes

Performance

Total duration: 1,077.95 ms -63.86 ms(-5.6%) | Renders: 76 (+0) | Paint: 1,769.81 ms -108.65 ms(-5.8%)

No significant changes — details


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

@netlify

netlify Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit b8bd647
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6aac5b6a2600520008ab2b6c
😎 Deploy Preview https://deploy-preview-5607--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 September 1, 2026 07:29

@jjenzz jjenzz left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like it just wants extra test coverage, I'll leave that to you.

DX review

The behavior change is sound: disabled triggers should follow normal button semantics now that Accordion is no longer a composite widget. However, the changed custom-element path lacks public-contract coverage.

Findings (1)

1. 🔴 Disabled custom triggers are changed without regression coverage

Source: AccordionTrigger.test.tsx:21, CollapsibleTrigger.test.tsx:32, useFocusableWhenDisabled.ts:30

Problem:

Removing focusableWhenDisabled: true changes both supported rendering modes, but the new tests cover only native buttons. With nativeButton={false}, the intended result is different: the element should retain aria-disabled, receive tabIndex={-1}, omit the native disabled attribute, and leave the tab order. The existing enabled non-native Accordion test does not verify that contract, and Collapsible has no equivalent coverage.

User scenario:

A design system renders either trigger as a styled <span> or link with nativeButton={false}. This upgrade should remove its disabled trigger from sequential focus while preserving non-native disabled semantics. A regression in disabled-state propagation or prop merging could leave that trigger tabbable while every new test still passes.

Requested changes:

Could we cover the non-native path for both triggers before merging? Please render a disabled trigger with nativeButton={false} and a non-button element, then assert aria-disabled="true", tabindex="-1", no disabled attribute, and that Tab skips it.

The native assertions in this PR should remain as-is. Together, the two cases will pin the complete behavior changed by removing focusableWhenDisabled, including the supported render composition path.

What is already sound

  • Removing the hardcoded focusability fixes the behavior at its source without adding a compatibility prop that would outlive the old composite implementation.
  • Native triggers now match Button semantics.
  • Keeping data-disabled stable preserves the documented styling hook.

Verdict

Request changes - The custom-element half of the changed public focus contract needs regression coverage. CC: @jjenzz


🤖 Review generated with Codex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: accordion Changes related to the accordion component. component: collapsible Changes related to the collapsible component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[accordion] disabled attribute isn't set on AccordionTrigger

2 participants