Skip to content

Commit

Permalink
a11y fixes for user profile input labels (#186471)
Browse files Browse the repository at this point in the history
## Summary

a11y fixes for user profile input labels. 
Screen readers announce "Change username, optional" or "Change email
address, optional" when inputs receive focus.


### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [x] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [x] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [x] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

__Fixes: https://github.com/elastic/kibana/issues/151934__

### Release note
a11y fixes for user profile input labels.

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
elena-shostak and kibanamachine authored Jun 21, 2024
1 parent 695d382 commit 32e5360
Showing 1 changed file with 23 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {
useEuiTheme,
useGeneratedHtmlId,
} from '@elastic/eui';
import { css } from '@emotion/react';
import { Form, FormikProvider, useFormik, useFormikContext } from 'formik';
import type { FunctionComponent } from 'react';
import React, { useRef, useState } from 'react';
Expand Down Expand Up @@ -64,6 +65,12 @@ import { FormRow, OptionalText } from '../../components/form_row';
import { ChangePasswordModal } from '../../management/users/edit_user/change_password_modal';
import { isUserReserved } from '../../management/users/user_utils';

const formRowCSS = css`
.euiFormRow__label {
flex: 1;
}
`;

export interface UserProfileProps {
user: AuthenticatedUser;
data?: UserProfileData;
Expand Down Expand Up @@ -128,30 +135,36 @@ const UserDetailsEditor: FunctionComponent<UserDetailsEditorProps> = ({ user })
}
>
<FormRow
css={formRowCSS}
label={
<FormLabel for="user.full_name">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.fullNameLabel"
defaultMessage="Full name"
/>
<EuiFlexGroup justifyContent="spaceBetween">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.fullNameLabel"
defaultMessage="Full name"
/>
<OptionalText />
</EuiFlexGroup>
</FormLabel>
}
labelAppend={<OptionalText />}
fullWidth
>
<FormField name="user.full_name" data-test-subj={'userProfileFullName'} fullWidth />
</FormRow>

<FormRow
css={formRowCSS}
label={
<FormLabel for="user.email">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.emailLabel"
defaultMessage="Email address"
/>
<EuiFlexGroup justifyContent="spaceBetween">
<FormattedMessage
id="xpack.security.accountManagement.userProfile.emailLabel"
defaultMessage="Email address"
/>
<OptionalText />
</EuiFlexGroup>
</FormLabel>
}
labelAppend={<OptionalText />}
fullWidth
>
<FormField type="email" name="user.email" data-test-subj={'userProfileEmail'} fullWidth />
Expand Down

0 comments on commit 32e5360

Please sign in to comment.