Skip to content

fix: add aria-disabled="true" to disabled & alwaysFocused chips #5674

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions chips/internal/assist-chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ export class AssistChip extends Chip {
class="primary action"
id="button"
aria-label=${ariaLabel || nothing}
aria-disabled=${this.disabled && this.alwaysFocusable
? 'true'
: nothing}
?disabled=${this.disabled && !this.alwaysFocusable}
type="button"
>${content}</button
Expand Down
11 changes: 11 additions & 0 deletions chips/internal/assist-chip_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,16 @@ describe('Assist chip', () => {
.withContext('should not have any disabled styling or behavior')
.toBeNull();
});

it('should use aria-disabled when disabled and alwaysFocusable', async () => {
const chip = await setupTest();
chip.disabled = true;
chip.alwaysFocusable = true;
await chip.updateComplete;

expect(chip.renderRoot.querySelector('button[aria-disabled="true"]'))
.withContext('should have aria-disabled="true"')
.not.toBeNull();
});
});
});
3 changes: 3 additions & 0 deletions chips/internal/filter-chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export class FilterChip extends MultiActionChip {
id="button"
aria-label=${ariaLabel || nothing}
aria-pressed=${this.selected}
aria-disabled=${this.disabled && this.alwaysFocusable
? 'true'
: nothing}
?disabled=${this.disabled && !this.alwaysFocusable}
@click=${this.handleClick}
>${content}</button
Expand Down
11 changes: 11 additions & 0 deletions chips/internal/filter-chip_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,16 @@ describe('Filter chip', () => {
.withContext('chip.selected reverts to true')
.toBeTrue();
});

it('should use aria-disabled when disabled and alwaysFocusable', async () => {
const {chip} = await setupTest();
chip.disabled = true;
chip.alwaysFocusable = true;
await chip.updateComplete;

expect(chip.renderRoot.querySelector('button[aria-disabled="true"]'))
.withContext('should have aria-disabled="true"')
.not.toBeNull();
});
});
});
3 changes: 3 additions & 0 deletions chips/internal/input-chip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ export class InputChip extends MultiActionChip {
class="primary action"
id="button"
aria-label=${ariaLabel || nothing}
aria-disabled=${this.disabled && this.alwaysFocusable
? 'true'
: nothing}
?disabled=${this.disabled && !this.alwaysFocusable}
type="button"
>${content}</button
Expand Down
11 changes: 11 additions & 0 deletions chips/internal/input-chip_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,16 @@ describe('Input chip', () => {
.withContext('should not have any disabled styling or behavior')
.toBeNull();
});

it('should use aria-disabled when disabled and alwaysFocusable', async () => {
const chip = await setupTest();
chip.disabled = true;
chip.alwaysFocusable = true;
await chip.updateComplete;

expect(chip.renderRoot.querySelector('button[aria-disabled="true"]'))
.withContext('should have aria-disabled="true"')
.not.toBeNull();
});
});
});
Loading