fix(select-rich): add aria-invalid when invalid
This commit is contained in:
parent
f9002d93bb
commit
db5f2ef38c
2 changed files with 31 additions and 0 deletions
|
|
@ -278,6 +278,11 @@ export class LionSelectRich extends OverlayMixin(
|
||||||
this._inputNode.getAttribute('aria-describedby'),
|
this._inputNode.getAttribute('aria-describedby'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changedProps.has('showsFeedbackFor')) {
|
||||||
|
// The ValidateMixin sets aria-invalid on the inputNode, but in this component we also need it on the invoker
|
||||||
|
this._invokerNode.setAttribute('aria-invalid', this._hasFeedbackVisibleFor('error'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -667,5 +667,31 @@ describe('lion-select-rich interactions', () => {
|
||||||
expect(oEl.getAttribute('aria-posinset')).to.equal(`${i + 1}`);
|
expect(oEl.getAttribute('aria-posinset')).to.equal(`${i + 1}`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('sets [aria-invalid="true"] to "._invokerNode" when there is an error', async () => {
|
||||||
|
const el = await fixture(html`
|
||||||
|
<lion-select-rich .validators=${[new Required()]}>
|
||||||
|
<lion-options slot="input">
|
||||||
|
<lion-option .choiceValue=${null}>Please select a value</lion-option>
|
||||||
|
<lion-option .modelValue=${{ value: 10, checked: true }}>Item 1</lion-option>
|
||||||
|
</lion-options>
|
||||||
|
</lion-select-rich>
|
||||||
|
`);
|
||||||
|
const invokerNode = el._invokerNode;
|
||||||
|
const options = el.querySelectorAll('lion-option');
|
||||||
|
await el.feedbackComplete;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(invokerNode.getAttribute('aria-invalid')).to.equal('false');
|
||||||
|
|
||||||
|
options[0].checked = true;
|
||||||
|
await el.feedbackComplete;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(invokerNode.getAttribute('aria-invalid')).to.equal('true');
|
||||||
|
|
||||||
|
options[1].checked = true;
|
||||||
|
await el.feedbackComplete;
|
||||||
|
await el.updateComplete;
|
||||||
|
expect(invokerNode.getAttribute('aria-invalid')).to.equal('false');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue