From b3d78e800ea0cf22ed8c3ebb9c1129b56728090b Mon Sep 17 00:00:00 2001 From: Jeramy Soucy Date: Thu, 30 Mar 2023 11:59:45 -0400 Subject: [PATCH] Improves screen reader features of combo boxes in edit role screen (#153808) ## Summary Related to #27749 While the [EuiComboBox rebuild](https://github.com/elastic/eui/issues/2841) is in progress, this PR addresses missing aria properties and fixes option announcements for the `run as user` combo. It additionally adds an aria-label for the Spaces Navigation EuiSelectable that I found was missing. ### Testing - Add all sample data - Edit a non-reserved role - Turn on a screen reader (NVDA is recommended, but VoiceOver will do) - Tab through the controls on the Edit role screen. When you arrive in a combo box you may or may not hear an announcement declaring the name of the combo box (this is expected, especially with VoiceOver). - With focus in a combo box press the down arrow key. Verify the options are announced as you traverse them with the down and up arrow keys. - If there was success in option announcement, press escape key and verify that the name of the combo box is announced. You may have to press escape twice when using NVDA. Note: It seems to be the consensus that this is best we can do with the existing implementation of EuiComboBox, which is partly why it is being rebuilt with the EuiSelectable component. --- .../cluster_privileges.test.tsx.snap | 1 + .../elasticsearch_privileges.test.tsx.snap | 37 +++++++--------- .../privileges/es/cluster_privileges.tsx | 6 +++ .../es/elasticsearch_privileges.tsx | 43 +++++++++--------- .../privileges/es/index_privilege_form.tsx | 44 +++++++++---------- .../nav_control/components/spaces_menu.tsx | 13 +++--- 6 files changed, 72 insertions(+), 72 deletions(-) diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/__snapshots__/cluster_privileges.test.tsx.snap b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/__snapshots__/cluster_privileges.test.tsx.snap index dd27fe13e84a3..ae57c00324ccd 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/__snapshots__/cluster_privileges.test.tsx.snap +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/__snapshots__/cluster_privileges.test.tsx.snap @@ -6,6 +6,7 @@ exports[`it renders without crashing 1`] = ` key="clusterPrivs" > } > - - - + { return ( {

} > - - ({ - id: username, - label: username, - isGroupLabelOption: false, - }))} - selectedOptions={this.props.role.elasticsearch.run_as.map((u) => ({ label: u }))} - onCreateOption={this.onCreateRunAsOption} - onChange={this.onRunAsUserChange} - isDisabled={!editable} - /> - + ({ + label: username, + isGroupLabelOption: false, + }))} + selectedOptions={this.props.role.elasticsearch.run_as.map((u) => ({ label: u }))} + onCreateOption={this.onCreateRunAsOption} + onChange={this.onRunAsUserChange} + isDisabled={!editable} + /> diff --git a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privilege_form.tsx b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privilege_form.tsx index fbc440c0ed984..934de8921ec88 100644 --- a/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privilege_form.tsx +++ b/x-pack/plugins/security/public/management/roles/edit_role/privileges/es/index_privilege_form.tsx @@ -241,18 +241,16 @@ export class IndexPrivilegeForm extends Component { ) : undefined } > - - - +
@@ -266,18 +264,16 @@ export class IndexPrivilegeForm extends Component { fullWidth={true} className="indexPrivilegeForm__deniedFieldsRow" > - - - + diff --git a/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx b/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx index 1d54c639d84d8..adad431cd05ea 100644 --- a/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx +++ b/x-pack/plugins/spaces/public/nav_control/components/spaces_menu.tsx @@ -20,7 +20,7 @@ import type { EuiSelectableOnChangeEvent, EuiSelectableSearchableSearchProps, } from '@elastic/eui/src/components/selectable/selectable'; -import React, { Component, lazy, Suspense } from 'react'; +import React, { Component, Fragment, lazy, Suspense } from 'react'; import type { ApplicationStart, Capabilities } from '@kbn/core/public'; import { i18n } from '@kbn/i18n'; @@ -85,8 +85,11 @@ class SpacesMenuUI extends Component { }; return ( - <> + { }} > {(list, search) => ( - <> + {search || i18n.translate('xpack.spaces.navControl.spacesMenu.selectSpacesTitle', { @@ -113,11 +116,11 @@ class SpacesMenuUI extends Component { })} {list} - + )} {this.renderManageButton()} - + ); }