Set aria-disabled to true or delete it (#2452)

fix: remove aria-disabled attribute
This commit is contained in:
Oleksii Kadurin 2025-01-22 12:16:56 +01:00 committed by GitHub
parent e6a33d92aa
commit a1d6dd90a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/ui': patch
---
[button] set the 'aria-disabled' attribute to 'true' when disabled and remove it when not disabled

View file

@ -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');
}
}
}

View file

@ -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;