Set aria-disabled to true or delete it (#2452)
fix: remove aria-disabled attribute
This commit is contained in:
parent
e6a33d92aa
commit
a1d6dd90a8
3 changed files with 11 additions and 2 deletions
5
.changeset/hip-nails-matter.md
Normal file
5
.changeset/hip-nails-matter.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@lion/ui': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
[button] set the 'aria-disabled' attribute to 'true' when disabled and remove it when not disabled
|
||||||
|
|
@ -149,7 +149,11 @@ export class LionButton extends DisabledWithTabIndexMixin(LitElement) {
|
||||||
super.updated(changedProperties);
|
super.updated(changedProperties);
|
||||||
|
|
||||||
if (changedProperties.has('disabled')) {
|
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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ export function LionButtonSuite({ klass = LionButton } = {}) {
|
||||||
el.disabled = false;
|
el.disabled = false;
|
||||||
await el.updateComplete;
|
await el.updateComplete;
|
||||||
expect(el.getAttribute('tabindex')).to.equal('0');
|
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);
|
expect(el.hasAttribute('disabled')).to.equal(false);
|
||||||
|
|
||||||
el.disabled = true;
|
el.disabled = true;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue