@@ -745,11 +719,8 @@ exports[`props options list is rendered 1`] = `
exports[`props selectedOptions are rendered 1`] = `
-
+
+
+
`;
exports[`props singleSelection selects existing option when opened 1`] = `
-
+
+
+
`;
diff --git a/src/components/combo_box/combo_box.test.tsx b/src/components/combo_box/combo_box.test.tsx
index 6825b82389a..f5801c64379 100644
--- a/src/components/combo_box/combo_box.test.tsx
+++ b/src/components/combo_box/combo_box.test.tsx
@@ -459,7 +459,7 @@ describe('behavior', () => {
>(
);
expect(inputRefCallback).toHaveBeenCalledTimes(1);
- expect(component.find('input[role="textbox"]').getDOMNode()).toBe(
+ expect(component.find('input[role="combobox"]').getDOMNode()).toBe(
inputRefCallback.mock.calls[0][0]
);
});
diff --git a/src/components/combo_box/combo_box.tsx b/src/components/combo_box/combo_box.tsx
index d7c591d41d8..719ec8dddeb 100644
--- a/src/components/combo_box/combo_box.tsx
+++ b/src/components/combo_box/combo_box.tsx
@@ -10,8 +10,6 @@
* Elements within EuiComboBox which would normally be tabbable (inputs, buttons) have been removed
* from the tab order with tabindex={-1} so that we can control the keyboard navigation interface.
*/
-/* eslint-disable jsx-a11y/role-has-required-aria-props */
-
import React, {
Component,
FocusEventHandler,
@@ -23,6 +21,7 @@ import classNames from 'classnames';
import { findPopoverPosition, htmlIdGenerator, keys } from '../../services';
import { EuiPortal } from '../portal';
+import { EuiI18n } from '../i18n';
import { EuiComboBoxOptionsList } from './combo_box_options_list';
import {
@@ -981,61 +980,64 @@ export class EuiComboBox
extends Component<
optionsList = (
-
+
+ {(listboxAriaLabel: string) => (
+
+ )}
+
);
}
return (
/**
- * Re: jsx-a11y/interactive-supports-focus
- * Focus is managed and is placed on the textbox element (`EuiComboBoxInput`)
- *
- * Re: jsx-a11y/role-has-required-aria-props
- * Expansion is managed and required `aria-controls` prop is placed on the textbox element (`EuiComboBoxInput`)
+ * EuiComboBox follows the WAI-ARIA 1.2 spec for editable comboboxes
+ * with list autocomplete. This pattern is an improvement on the user
+ * experience for screen readers over the WAI-ARIA 1.1 pattern.
*
- * Reference for both: https://www.w3.org/TR/2017/REC-wai-aria-1.1-20171214/#combobox,
- * which verifies that this implementation follows the spec.
+ * https://www.w3.org/TR/wai-aria-practices-1.2/examples/combobox/combobox-autocomplete-list.html
*/
- // eslint-disable-next-line jsx-a11y/interactive-supports-focus
extends Component<
// reader.
removeOptionMessage = (
-
+
{removeOptionMessageContent}
@@ -251,6 +251,7 @@ export class EuiComboBoxInput extends Component<
onClick: isListOpen && !isDisabled ? onCloseListClick : onOpenListClick,
ref: toggleButtonRef,
side: 'right',
+ tabIndex: -1,
type: 'arrowDown',
};
}
@@ -284,10 +285,12 @@ export class EuiComboBoxInput extends Component<
{!singleSelection || !searchValue ? pills : null}
{placeholderMessage}
extends Component<
onChange={this.inputOnChange}
onFocus={this.onFocus}
ref={this.inputRefCallback}
- role="textbox"
+ role="combobox"
style={{ fontSize: 14 }}
value={searchValue}
autoFocus={autoFocus}
diff --git a/src/components/combo_box/combo_box_options_list/combo_box_options_list.tsx b/src/components/combo_box/combo_box_options_list/combo_box_options_list.tsx
index ed8082a2aea..63a401a862d 100644
--- a/src/components/combo_box/combo_box_options_list/combo_box_options_list.tsx
+++ b/src/components/combo_box/combo_box_options_list/combo_box_options_list.tsx
@@ -49,6 +49,7 @@ export type EuiComboBoxOptionsListProps = CommonProps &
'data-test-subj': string;
activeOptionIndex?: number;
areAllOptionsSelected?: boolean;
+ listboxAriaLabel: string;
/**
* Creates a custom text option. You can use `{searchValue}` inside your string to better customize your text.
* It won't show if there's no onCreateOption.
@@ -194,8 +195,9 @@ export class EuiComboBoxOptionsList extends Component<
this.listBoxRef = ref;
if (ref) {
+ ref.setAttribute('aria-label', this.props.listboxAriaLabel);
ref.setAttribute('id', this.props.rootId('listbox'));
- ref.setAttribute('role', 'listBox');
+ ref.setAttribute('role', 'listbox');
ref.setAttribute('tabIndex', '0');
}
};
@@ -307,6 +309,7 @@ export class EuiComboBoxOptionsList extends Component<
delimiter,
zIndex,
style,
+ listboxAriaLabel,
...rest
} = this.props;