Skip to content

Commit

Permalink
fix(form-core): set aria-disabled next to the disabled attribute for …
Browse files Browse the repository at this point in the history
…NVDA screen reader
  • Loading branch information
gerjanvangeest authored and tlouisse committed Feb 19, 2024
1 parent 059b018 commit 19256d3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-otters-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lion/ui': patch
---

[form-core]: set aria-disabled next to the disabled attribute for NVDA screen reader
4 changes: 4 additions & 0 deletions packages/ui/components/form-core/src/FormControlMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 15 additions & 0 deletions packages/ui/components/form-core/test/FormControlMixin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} */ (
Expand Down

0 comments on commit 19256d3

Please sign in to comment.