Commit 8dbe13e2 authored by Lyza Danger Gardner's avatar Lyza Danger Gardner Committed by Lyza Gardner

Fix accessibility: move `combobox` role to input in `TagEditor`

Assign `combobox` role to `input` instead of container element in
`TagEditor`.  Remove unneeded `aria-owns` attribute.

This obviates the need to disable any axe-core accessibility tests and
makes tests pass for axe-core v4.6.2.
parent d8104e8e
......@@ -262,12 +262,6 @@ function TagEditor({
id={tagEditorId}
data-testid="combobox-container"
ref={closeWrapperRef}
// Disabled because aria-controls must be attached to the <input> field
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
role="combobox"
aria-expanded={suggestionsListOpen.toString()}
aria-owns={`${tagEditorId}-AutocompleteList`}
aria-haspopup="listbox"
>
<Input
onInput={handleOnInput}
......@@ -280,8 +274,10 @@ function TagEditor({
aria-autocomplete="list"
aria-activedescendant={activeDescendant}
aria-controls={`${tagEditorId}-AutocompleteList`}
aria-expanded={suggestionsListOpen.toString()}
aria-label="Add tags"
dir="auto"
role="combobox"
/>
<AutocompleteList
id={`${tagEditorId}-AutocompleteList`}
......
......@@ -453,7 +453,7 @@ describe('TagEditor', () => {
});
describe('accessibility attributes and ids', () => {
const comboboxSelector = '[data-testid="combobox-container"]';
const comboboxSelector = 'input[role="combobox"]';
it('creates multiple <TagEditor> components with unique AutocompleteList `id` props', () => {
const wrapper1 = createComponent();
const wrapper2 = createComponent();
......@@ -463,16 +463,6 @@ describe('TagEditor', () => {
);
});
it('sets the <AutocompleteList> `id` prop to the same value as the `aria-owns` attribute', () => {
const wrapper = createComponent();
wrapper.find('AutocompleteList');
assert.equal(
wrapper.find(comboboxSelector).prop('aria-owns'),
wrapper.find('AutocompleteList').prop('id')
);
});
it('sets `aria-expanded` value to match open state', () => {
const wrapper = createComponent();
wrapper.find('input').instance().value = 'non-empty'; // to open list
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment