fix(button): aria-disabled for button and switch
This commit is contained in:
parent
f15de48fbf
commit
31ccb4a10f
4 changed files with 20 additions and 0 deletions
|
|
@ -184,6 +184,9 @@ export class LionButton extends DisabledWithTabIndexMixin(SlotMixin(LitElement))
|
|||
native.type = this.type;
|
||||
}
|
||||
}
|
||||
if (changedProperties.has('disabled')) {
|
||||
this.setAttribute('aria-disabled', `${this.disabled}`); // create mixin if we need it in more places
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -57,15 +57,18 @@ describe('lion-button', () => {
|
|||
it('can be disabled imperatively', async () => {
|
||||
const el = await fixture(`<lion-button disabled>foo</lion-button>`);
|
||||
expect(el.getAttribute('tabindex')).to.equal('-1');
|
||||
expect(el.getAttribute('aria-disabled')).to.equal('true');
|
||||
|
||||
el.disabled = false;
|
||||
await el.updateComplete;
|
||||
expect(el.getAttribute('tabindex')).to.equal('0');
|
||||
expect(el.getAttribute('aria-disabled')).to.equal('false');
|
||||
expect(el.hasAttribute('disabled')).to.equal(false);
|
||||
|
||||
el.disabled = true;
|
||||
await el.updateComplete;
|
||||
expect(el.getAttribute('tabindex')).to.equal('-1');
|
||||
expect(el.getAttribute('aria-disabled')).to.equal('true');
|
||||
expect(el.hasAttribute('disabled')).to.equal(true);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -113,6 +113,12 @@ export class LionSwitchButton extends DisabledWithTabIndexMixin(LitElement) {
|
|||
}
|
||||
}
|
||||
|
||||
updated(changedProperties) {
|
||||
if (changedProperties.has('disabled')) {
|
||||
this.setAttribute('aria-disabled', `${this.disabled}`); // create mixin if we need it in more places
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We synchronously update aria-checked to support voice over on safari.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -108,4 +108,12 @@ describe('lion-switch-button', () => {
|
|||
expect(el.getAttribute('aria-checked')).to.equal('false');
|
||||
});
|
||||
});
|
||||
it('should manage "aria-disabled"', async () => {
|
||||
el.disabled = true;
|
||||
await el.updateComplete;
|
||||
expect(el.getAttribute('aria-disabled')).to.equal('true');
|
||||
el.disabled = false;
|
||||
await el.updateComplete;
|
||||
expect(el.getAttribute('aria-disabled')).to.equal('false');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue