Skip to content

fix(cdk-experimental/accordion): fix disabled trigger button can't be focused when skipDisabled=false #31379

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/cdk-experimental/accordion/accordion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ export class CdkAccordionPanel {
'[attr.aria-expanded]': 'pattern.expanded()',
'[attr.aria-controls]': 'pattern.controls()',
'[attr.aria-disabled]': 'pattern.disabled()',
'[attr.inert]': 'hardDisabled() ? true : null',
'[attr.disabled]': 'hardDisabled() ? true : null',
'[attr.tabindex]': 'pattern.tabindex()',
'(keydown)': 'pattern.onKeydown($event)',
'(pointerdown)': 'pattern.onPointerdown($event)',
Expand All @@ -115,6 +117,13 @@ export class CdkAccordionTrigger {
/** Whether the trigger is disabled. */
disabled = input(false, {transform: booleanAttribute});

/**
* Whether this trigger is completely inaccessible.
*
* TODO(ok7sai): Consider move this to UI patterns.
*/
readonly hardDisabled = computed(() => this.pattern.disabled() && this.pattern.tabindex() < 0);

/** The accordion panel pattern controlled by this trigger. This is set by CdkAccordionGroup. */
readonly accordionPanel: WritableSignal<AccordionPanelPattern | undefined> = signal(undefined);

Expand Down
Loading