Repository navigation
[accordion][collapsible] Apply the native disabled attribute to triggers - #5607
Conversation
commit: |
Bundle size
PerformanceTotal 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. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
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 assertaria-disabled="true",tabindex="-1", nodisabledattribute, 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 supportedrendercomposition 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
Buttonsemantics. - Keeping
data-disabledstable 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
Fixes #4114
Disabled Accordion and Collapsible triggers rendered
aria-disabledand stayed in the tab order. ThefocusableWhenDisabled: truehardcode is a leftover from Accordion's composite days (arrow-key navigation was removed in #4965), so the triggers now matchButtonand the other plain triggers: when disabled, native triggers render thedisabledattribute, while non-native triggers keeparia-disabled="true"and receivetabindex="-1".Changes
focusableWhenDisabled: truefromAccordion.TriggerandCollapsible.Trigger.disabledattributes and non-nativearia-disabled/tabindexattributes 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-disabledis replaced bydisabled, so[aria-disabled]CSS selectors stop matching. Non-native triggers keeparia-disabled="true"and receivetabindex="-1", without adisabledattribute. The documented styling hookdata-disabledis unchanged, so this stays within the semver contract, but the changelog should call it out. In particular, therender={<Button />}workaround posted in #4114 must be removed after upgrading: it computesdisabledfromprops['aria-disabled'], which is no longer set, so leaving it in place renders an enabled-looking (though still inert) button.