fix(form-core): set aria-disabled next to the disabled attribute for NVDA screen reader
This commit is contained in:
parent
059b018793
commit
19256d31bf
3 changed files with 24 additions and 0 deletions
5
.changeset/polite-otters-sort.md
Normal file
5
.changeset/polite-otters-sort.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@lion/ui': patch
|
||||
---
|
||||
|
||||
[form-core]: set aria-disabled next to the disabled attribute for NVDA screen reader
|
||||
|
|
@ -276,6 +276,10 @@ const FormControlMixinImplementation = superclass =>
|
|||
updated(changedProperties) {
|
||||
super.updated(changedProperties);
|
||||
|
||||
if (changedProperties.has('disabled')) {
|
||||
this._inputNode?.setAttribute('aria-disabled', this.disabled.toString());
|
||||
}
|
||||
|
||||
if (changedProperties.has('_ariaLabelledNodes')) {
|
||||
this.__reflectAriaAttr(
|
||||
'aria-labelledby',
|
||||
|
|
|
|||
|
|
@ -198,6 +198,21 @@ describe('FormControlMixin', () => {
|
|||
expect(descriptionIdsBefore).to.equal(descriptionIdsAfter);
|
||||
});
|
||||
|
||||
it('sets aria-disabled on inputNode based on disabled property', async () => {
|
||||
const el = /** @type {FormControlMixinClass} */ (
|
||||
await fixture(html`
|
||||
<${tag}>${inputSlot}</${tag}>
|
||||
`)
|
||||
);
|
||||
const { _inputNode } = getFormControlMembers(el);
|
||||
expect(_inputNode.hasAttribute('aria-disabled')).to.be.true;
|
||||
expect(_inputNode.getAttribute('aria-disabled')).to.equal('false');
|
||||
|
||||
el.disabled = true;
|
||||
|
||||
expect(_inputNode.getAttribute('aria-disabled')).to.equal('false');
|
||||
});
|
||||
|
||||
it('clicking the label should call `_onLabelClick`', async () => {
|
||||
const spy = sinon.spy();
|
||||
const el = /** @type {FormControlMixinClass} */ (
|
||||
|
|
|
|||
Loading…
Reference in a new issue