Skip to content

Commit

Permalink
Set aria-disabled to true or delete it (#2452)
Browse files Browse the repository at this point in the history
fix: remove aria-disabled attribute
  • Loading branch information
okadurin authored Jan 22, 2025
1 parent e6a33d9 commit a1d6dd9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/hip-nails-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lion/ui': patch
---

[button] set the 'aria-disabled' attribute to 'true' when disabled and remove it when not disabled
6 changes: 5 additions & 1 deletion packages/ui/components/button/src/LionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ export class LionButton extends DisabledWithTabIndexMixin(LitElement) {
super.updated(changedProperties);

if (changedProperties.has('disabled')) {
this.setAttribute('aria-disabled', `${this.disabled}`); // create mixin if we need it in more places
if (this.disabled) {
this.setAttribute('aria-disabled', 'true');
} else if (this.getAttribute('aria-disabled') !== null) {
this.removeAttribute('aria-disabled');
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function LionButtonSuite({ klass = LionButton } = {}) {
el.disabled = false;
await el.updateComplete;
expect(el.getAttribute('tabindex')).to.equal('0');
expect(el.getAttribute('aria-disabled')).to.equal('false');
expect(el.getAttribute('aria-disabled')).to.not.exist;
expect(el.hasAttribute('disabled')).to.equal(false);

el.disabled = true;
Expand Down

0 comments on commit a1d6dd9

Please sign in to comment.