diff --git a/packages/eui/changelogs/upcoming/9850.md b/packages/eui/changelogs/upcoming/9850.md new file mode 100644 index 000000000000..07d246153288 --- /dev/null +++ b/packages/eui/changelogs/upcoming/9850.md @@ -0,0 +1,4 @@ +**Accessibility** + +- Improved the accessibility of `EuiSelectable` by removing the redundant "Checked option." screen reader text from checked options, which caused screen readers to announce the checked state twice (the state is already conveyed via `aria-checked`/`aria-selected`) +- Improved the accessibility of `EuiSelectable` and `EuiComboBox` by moving the `title` attribute from the option element to its inner text element. On the option, it became the option's accessible description, causing screen readers to announce the option name twice diff --git a/packages/eui/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap b/packages/eui/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap index a470076b9cbb..e286c0754216 100644 --- a/packages/eui/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap +++ b/packages/eui/src/components/combo_box/__snapshots__/combo_box.test.tsx.snap @@ -180,13 +180,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-0" role="option" style="position: absolute; left: 0px; top: 0px; height: 29px; width: 100%;" - title="Titan" > Titan @@ -201,13 +201,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-1" role="option" style="position: absolute; left: 0px; top: 29px; height: 29px; width: 100%;" - title="Enceladus" > Enceladus @@ -222,13 +222,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-2" role="option" style="position: absolute; left: 0px; top: 58px; height: 29px; width: 100%;" - title="Mimas" > Mimas @@ -243,13 +243,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-3" role="option" style="position: absolute; left: 0px; top: 87px; height: 29px; width: 100%;" - title="Dione" > Dione @@ -264,13 +264,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-4" role="option" style="position: absolute; left: 0px; top: 116px; height: 29px; width: 100%;" - title="Iapetus" > Iapetus @@ -285,13 +285,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-5" role="option" style="position: absolute; left: 0px; top: 145px; height: 29px; width: 100%;" - title="Phoebe" > Phoebe @@ -306,13 +306,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-6" role="option" style="position: absolute; left: 0px; top: 174px; height: 29px; width: 100%;" - title="Rhea" > Rhea @@ -327,13 +327,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-7" role="option" style="position: absolute; left: 0px; top: 203px; height: 29px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -348,13 +348,13 @@ exports[`EuiComboBox renders the options list dropdown 1`] = ` id="generated-id__option-8" role="option" style="position: absolute; left: 0px; top: 232px; height: 29px; width: 100%;" - title="Tethys" > Tethys diff --git a/packages/eui/src/components/combo_box/combo_box_options_list/combo_box_options_list.tsx b/packages/eui/src/components/combo_box/combo_box_options_list/combo_box_options_list.tsx index 5c6d1328763b..fe77401a5881 100644 --- a/packages/eui/src/components/combo_box/combo_box_options_list/combo_box_options_list.tsx +++ b/packages/eui/src/components/combo_box/combo_box_options_list/combo_box_options_list.tsx @@ -255,7 +255,6 @@ export class EuiComboBoxOptionsList extends Component< // uses the original `options` array for the index to ensure a stable `id`, otherwise `aria-activedescendant` // loses focus on selecting an option (due to actively removing it from the list) id={rootId(`_option-${options.indexOf(option)}`)} - title={hasNativeTruncation && !toolTipContent ? label : undefined} key={option.key ?? option.label} prepend={option.prepend} append={ @@ -289,6 +288,12 @@ export class EuiComboBoxOptionsList extends Component< contentProps={{ className: 'euiComboBoxOption__content', }} + textProps={{ + // `title` must not be set on the option element itself - it would + // become the option's accessible description, causing screen readers + // to announce the option name twice + title: hasNativeTruncation && !toolTipContent ? label : undefined, + }} onClick={() => { if (onOptionClick) { onOptionClick(option); diff --git a/packages/eui/src/components/filter_group/filter_group.a11y.tsx b/packages/eui/src/components/filter_group/filter_group.a11y.tsx index 41c82864b157..2e4fa967dfed 100644 --- a/packages/eui/src/components/filter_group/filter_group.a11y.tsx +++ b/packages/eui/src/components/filter_group/filter_group.a11y.tsx @@ -259,7 +259,7 @@ describe('EuiFilterGroup multiselect example', () => { .find('span.euiSelectableListItem__text') .should( 'have.text', - 'Dmitri Shostakovich. Checked option. To exclude this option, press Enter.' + 'Dmitri Shostakovich. To exclude this option, press Enter.' ); }); cy.realPress('ArrowDown'); diff --git a/packages/eui/src/components/list_item_layout/_list_item_layout.tsx b/packages/eui/src/components/list_item_layout/_list_item_layout.tsx index e25bed36f87c..752d8833d72b 100644 --- a/packages/eui/src/components/list_item_layout/_list_item_layout.tsx +++ b/packages/eui/src/components/list_item_layout/_list_item_layout.tsx @@ -95,7 +95,7 @@ export type EuiListItemLayoutSharedProps = CommonProps & /** * Props applied to the label text element. */ - textProps?: CommonProps; + textProps?: CommonProps & HTMLAttributes; prependProps?: CommonProps; appendProps?: CommonProps; tooltipProps?: Omit; diff --git a/packages/eui/src/components/selectable/__snapshots__/selectable.test.tsx.snap b/packages/eui/src/components/selectable/__snapshots__/selectable.test.tsx.snap index 88fff0dffec8..4ff97b1724d9 100644 --- a/packages/eui/src/components/selectable/__snapshots__/selectable.test.tsx.snap +++ b/packages/eui/src/components/selectable/__snapshots__/selectable.test.tsx.snap @@ -32,7 +32,6 @@ exports[`EuiSelectable custom options with data 1`] = ` id="generated-id_listbox_option-0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > VI @@ -66,7 +66,6 @@ exports[`EuiSelectable custom options with data 1`] = ` id="generated-id_listbox_option-1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > II @@ -100,7 +100,6 @@ exports[`EuiSelectable custom options with data 1`] = ` id="generated-id_listbox_option-2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > XVII @@ -180,7 +180,6 @@ exports[`EuiSelectable errorMessage prop does not render the message when not de id="generated-id_listbox_option-0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan @@ -210,7 +210,6 @@ exports[`EuiSelectable errorMessage prop does not render the message when not de id="generated-id_listbox_option-1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -240,7 +240,6 @@ exports[`EuiSelectable errorMessage prop does not render the message when not de id="generated-id_listbox_option-2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology diff --git a/packages/eui/src/components/selectable/selectable_list/__snapshots__/selectable_list.test.tsx.snap b/packages/eui/src/components/selectable/selectable_list/__snapshots__/selectable_list.test.tsx.snap index d3388220526a..1f56334870c4 100644 --- a/packages/eui/src/components/selectable/selectable_list/__snapshots__/selectable_list.test.tsx.snap +++ b/packages/eui/src/components/selectable/selectable_list/__snapshots__/selectable_list.test.tsx.snap @@ -30,7 +30,6 @@ exports[`EuiSelectableListItem group labels handles updating aria attrs correctl data-test-subj="euiListItemLayout" id="option_1" role="option" - title="Titan" > Titan @@ -55,7 +55,6 @@ exports[`EuiSelectableListItem group labels handles updating aria attrs correctl data-test-subj="euiListItemLayout" id="option_2" role="option" - title="Io" > Io @@ -86,7 +86,6 @@ exports[`EuiSelectableListItem group labels handles updating aria attrs correctl data-test-subj="euiListItemLayout" id="option_4" role="option" - title="Mercury" > Mercury @@ -111,7 +111,6 @@ exports[`EuiSelectableListItem group labels handles updating aria attrs correctl data-test-subj="euiListItemLayout" id="option_5" role="option" - title="Mars" > Mars @@ -142,7 +142,6 @@ exports[`EuiSelectableListItem group labels handles updating aria attrs correctl data-test-subj="euiListItemLayout" id="option_7" role="option" - title="Sol" > Sol @@ -194,7 +194,6 @@ exports[`EuiSelectableListItem group labels renders with correct aria-setsize an id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Spaaaace" > Spaaaace @@ -227,7 +227,6 @@ exports[`EuiSelectableListItem group labels renders with correct aria-setsize an id="option_2" role="option" style="position: absolute; left: 0px; top: 80px; height: 32px; width: 100%;" - title="Titan" > Titan @@ -253,7 +253,6 @@ exports[`EuiSelectableListItem group labels renders with correct aria-setsize an id="option_3" role="option" style="position: absolute; left: 0px; top: 112px; height: 32px; width: 100%;" - title="Io" > Io @@ -286,7 +286,6 @@ exports[`EuiSelectableListItem group labels renders with correct aria-setsize an id="option_5" role="option" style="position: absolute; left: 0px; top: 192px; height: 32px; width: 100%;" - title="Mercury" > Mercury @@ -312,7 +312,6 @@ exports[`EuiSelectableListItem group labels renders with correct aria-setsize an id="option_6" role="option" style="position: absolute; left: 0px; top: 224px; height: 32px; width: 100%;" - title="Mars" > Mars @@ -372,7 +372,6 @@ exports[`EuiSelectableListItem is rendered 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan @@ -398,7 +398,6 @@ exports[`EuiSelectableListItem is rendered 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -424,7 +424,6 @@ exports[`EuiSelectableListItem is rendered 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -450,7 +450,6 @@ exports[`EuiSelectableListItem is rendered 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -476,7 +476,6 @@ exports[`EuiSelectableListItem is rendered 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -502,7 +502,6 @@ exports[`EuiSelectableListItem is rendered 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion @@ -555,7 +555,6 @@ exports[`EuiSelectableListItem props activeOptionIndex 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan @@ -581,7 +581,6 @@ exports[`EuiSelectableListItem props activeOptionIndex 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -607,7 +607,6 @@ exports[`EuiSelectableListItem props activeOptionIndex 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -633,7 +633,6 @@ exports[`EuiSelectableListItem props activeOptionIndex 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -659,7 +659,6 @@ exports[`EuiSelectableListItem props activeOptionIndex 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -685,7 +685,6 @@ exports[`EuiSelectableListItem props activeOptionIndex 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion @@ -738,7 +738,6 @@ exports[`EuiSelectableListItem props allowExclusions 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan
Enceladus
Mimas
Pandora is one of Saturn's moons, named for a Titaness of Greek mythology
Tethys
Hyperion
Titan @@ -983,7 +983,6 @@ exports[`EuiSelectableListItem props bordered 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -1009,7 +1009,6 @@ exports[`EuiSelectableListItem props bordered 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -1035,7 +1035,6 @@ exports[`EuiSelectableListItem props bordered 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -1061,7 +1061,6 @@ exports[`EuiSelectableListItem props bordered 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -1087,7 +1087,6 @@ exports[`EuiSelectableListItem props bordered 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion @@ -1140,7 +1140,6 @@ exports[`EuiSelectableListItem props height is forced 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan @@ -1166,7 +1166,6 @@ exports[`EuiSelectableListItem props height is forced 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -1192,7 +1192,6 @@ exports[`EuiSelectableListItem props height is forced 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -1218,7 +1218,6 @@ exports[`EuiSelectableListItem props height is forced 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -1244,7 +1244,6 @@ exports[`EuiSelectableListItem props height is forced 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -1270,7 +1270,6 @@ exports[`EuiSelectableListItem props height is forced 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion @@ -1323,7 +1323,6 @@ exports[`EuiSelectableListItem props height is full 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan @@ -1349,7 +1349,6 @@ exports[`EuiSelectableListItem props height is full 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -1375,7 +1375,6 @@ exports[`EuiSelectableListItem props height is full 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -1401,7 +1401,6 @@ exports[`EuiSelectableListItem props height is full 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -1427,7 +1427,6 @@ exports[`EuiSelectableListItem props height is full 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -1453,7 +1453,6 @@ exports[`EuiSelectableListItem props height is full 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion @@ -1500,7 +1500,6 @@ exports[`EuiSelectableListItem props isVirtualized={false} renders 1`] = ` data-test-subj="titanOption" id="option_0" role="option" - title="Titan" > Titan @@ -1525,7 +1525,6 @@ exports[`EuiSelectableListItem props isVirtualized={false} renders 1`] = ` data-test-subj="euiListItemLayout" id="option_1" role="option" - title="Enceladus" > Enceladus @@ -1550,7 +1550,6 @@ exports[`EuiSelectableListItem props isVirtualized={false} renders 1`] = ` data-test-subj="euiListItemLayout" id="option_2" role="option" - title="Mimas" > Mimas @@ -1575,7 +1575,6 @@ exports[`EuiSelectableListItem props isVirtualized={false} renders 1`] = ` data-test-subj="euiListItemLayout" id="option_3" role="option" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -1600,7 +1600,6 @@ exports[`EuiSelectableListItem props isVirtualized={false} renders 1`] = ` data-test-subj="euiListItemLayout" id="option_4" role="option" - title="Tethys" > Tethys @@ -1625,7 +1625,6 @@ exports[`EuiSelectableListItem props isVirtualized={false} renders 1`] = ` data-test-subj="euiListItemLayout" id="option_5" role="option" - title="Hyperion" > Hyperion @@ -1677,7 +1677,6 @@ exports[`EuiSelectableListItem props renderOption 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > => @@ -1706,7 +1706,6 @@ exports[`EuiSelectableListItem props renderOption 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > => @@ -1735,7 +1735,6 @@ exports[`EuiSelectableListItem props renderOption 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > => @@ -1764,7 +1764,6 @@ exports[`EuiSelectableListItem props renderOption 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > => @@ -1793,7 +1793,6 @@ exports[`EuiSelectableListItem props renderOption 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > => @@ -1822,7 +1822,6 @@ exports[`EuiSelectableListItem props renderOption 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > => @@ -1878,7 +1878,6 @@ exports[`EuiSelectableListItem props rowHeight 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 20px; width: 100%;" - title="Titan" > Titan @@ -1904,7 +1904,6 @@ exports[`EuiSelectableListItem props rowHeight 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 20px; height: 20px; width: 100%;" - title="Enceladus" > Enceladus @@ -1930,7 +1930,6 @@ exports[`EuiSelectableListItem props rowHeight 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 40px; height: 20px; width: 100%;" - title="Mimas" > Mimas @@ -1956,7 +1956,6 @@ exports[`EuiSelectableListItem props rowHeight 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 60px; height: 20px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -1982,7 +1982,6 @@ exports[`EuiSelectableListItem props rowHeight 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 80px; height: 20px; width: 100%;" - title="Tethys" > Tethys @@ -2008,7 +2008,6 @@ exports[`EuiSelectableListItem props rowHeight 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 100px; height: 20px; width: 100%;" - title="Hyperion" > Hyperion @@ -2059,7 +2059,6 @@ exports[`EuiSelectableListItem props searchable enables correct screen reader in id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan
Enceladus
Mimas
Pandora is one of Saturn's moons, named for a Titaness of Greek mythology
Tethys
Hyperion
Titan @@ -2299,13 +2299,13 @@ exports[`EuiSelectableListItem props showIcons can be turned off 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -2320,13 +2320,13 @@ exports[`EuiSelectableListItem props showIcons can be turned off 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -2341,13 +2341,13 @@ exports[`EuiSelectableListItem props showIcons can be turned off 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -2362,13 +2362,13 @@ exports[`EuiSelectableListItem props showIcons can be turned off 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -2383,13 +2383,13 @@ exports[`EuiSelectableListItem props showIcons can be turned off 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion @@ -2430,7 +2430,6 @@ exports[`EuiSelectableListItem props singleSelection can be forced so that at le id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan @@ -2456,7 +2456,6 @@ exports[`EuiSelectableListItem props singleSelection can be forced so that at le id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -2482,7 +2482,6 @@ exports[`EuiSelectableListItem props singleSelection can be forced so that at le id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -2508,7 +2508,6 @@ exports[`EuiSelectableListItem props singleSelection can be forced so that at le id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -2534,7 +2534,6 @@ exports[`EuiSelectableListItem props singleSelection can be forced so that at le id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -2560,7 +2560,6 @@ exports[`EuiSelectableListItem props singleSelection can be forced so that at le id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion @@ -2612,7 +2612,6 @@ exports[`EuiSelectableListItem props singleSelection can be turned on 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Titan" > Titan @@ -2638,7 +2638,6 @@ exports[`EuiSelectableListItem props singleSelection can be turned on 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Enceladus" > Enceladus @@ -2664,7 +2664,6 @@ exports[`EuiSelectableListItem props singleSelection can be turned on 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -2690,7 +2690,6 @@ exports[`EuiSelectableListItem props singleSelection can be turned on 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -2716,7 +2716,6 @@ exports[`EuiSelectableListItem props singleSelection can be turned on 1`] = ` id="option_4" role="option" style="position: absolute; left: 0px; top: 128px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -2742,7 +2742,6 @@ exports[`EuiSelectableListItem props singleSelection can be turned on 1`] = ` id="option_5" role="option" style="position: absolute; left: 0px; top: 160px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion @@ -2795,7 +2795,6 @@ exports[`EuiSelectableListItem props visibleOptions 1`] = ` id="option_0" role="option" style="position: absolute; left: 0px; top: 0px; height: 32px; width: 100%;" - title="Mimas" > Mimas @@ -2821,7 +2821,6 @@ exports[`EuiSelectableListItem props visibleOptions 1`] = ` id="option_1" role="option" style="position: absolute; left: 0px; top: 32px; height: 32px; width: 100%;" - title="Pandora is one of Saturn's moons, named for a Titaness of Greek mythology" > Pandora is one of Saturn's moons, named for a Titaness of Greek mythology @@ -2847,7 +2847,6 @@ exports[`EuiSelectableListItem props visibleOptions 1`] = ` id="option_2" role="option" style="position: absolute; left: 0px; top: 64px; height: 32px; width: 100%;" - title="Tethys" > Tethys @@ -2873,7 +2873,6 @@ exports[`EuiSelectableListItem props visibleOptions 1`] = ` id="option_3" role="option" style="position: absolute; left: 0px; top: 96px; height: 32px; width: 100%;" - title="Hyperion" > Hyperion diff --git a/packages/eui/src/components/selectable/selectable_list/__snapshots__/selectable_list_item.test.tsx.snap b/packages/eui/src/components/selectable/selectable_list/__snapshots__/selectable_list_item.test.tsx.snap index c4e52d64462d..2f11c5537f72 100644 --- a/packages/eui/src/components/selectable/selectable_list/__snapshots__/selectable_list_item.test.tsx.snap +++ b/packages/eui/src/components/selectable/selectable_list/__snapshots__/selectable_list_item.test.tsx.snap @@ -136,8 +136,6 @@ exports[`EuiSelectableListItem props checked & allowExclusions on 1`] = ` class="emotion-euiScreenReaderOnly" > . - Checked option. - To exclude this option, press Enter.
@@ -196,8 +194,6 @@ exports[`EuiSelectableListItem props checked & searchable on 1`] = ` class="emotion-euiScreenReaderOnly" > . - Checked option. - To uncheck this option, press Enter.
@@ -284,14 +280,7 @@ exports[`EuiSelectableListItem props checked on 1`] = ` /> -
- . - Checked option. -
-
+ />
`; diff --git a/packages/eui/src/components/selectable/selectable_list/selectable_list_item.test.tsx b/packages/eui/src/components/selectable/selectable_list/selectable_list_item.test.tsx index 74c7703cdcf0..4bd94408068e 100644 --- a/packages/eui/src/components/selectable/selectable_list/selectable_list_item.test.tsx +++ b/packages/eui/src/components/selectable/selectable_list/selectable_list_item.test.tsx @@ -129,6 +129,21 @@ describe('EuiSelectableListItem', () => { }); }); + test('title is rendered on the text element instead of the option element', () => { + const { getByRole, container } = render( + + Test option + + ); + + // a `title` on the option element would become its accessible + // description, causing screen readers to announce the name twice + expect(getByRole('option')).not.toHaveAttribute('title'); + expect( + container.querySelector('.euiSelectableListItem__text') + ).toHaveAttribute('title', 'Test option'); + }); + test('showIcons can be turned off', () => { const { container } = render(); diff --git a/packages/eui/src/components/selectable/selectable_list/selectable_list_item.tsx b/packages/eui/src/components/selectable/selectable_list/selectable_list_item.tsx index b61f3a3f5fb7..c939b1434e5b 100644 --- a/packages/eui/src/components/selectable/selectable_list/selectable_list_item.tsx +++ b/packages/eui/src/components/selectable/selectable_list/selectable_list_item.tsx @@ -94,6 +94,7 @@ export const EuiSelectableListItem: FunctionComponent< searchable, toolTipContent, toolTipProps, + title, ...rest }) => { const classes = classNames( @@ -140,12 +141,6 @@ export const EuiSelectableListItem: FunctionComponent< const screenReaderStrings = { checked: { - state: ( - - ), instructions: (