Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiFieldSearch] update clear button aria-label #7970

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/eui/changelogs/upcoming/7970.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
**Accessibility**

- Updated the `aria-label` attribute for the `EuiFieldSearch` clear button
74 changes: 43 additions & 31 deletions packages/eui/src/components/form/field_search/field_search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
import React, { Component, InputHTMLAttributes, KeyboardEvent } from 'react';
import classNames from 'classnames';

import { Browser } from '../../../services/browser';
import { CommonProps } from '../../common';
import {
keys,
withEuiStylesMemoizer,
WithEuiStylesMemoizerProps,
} from '../../../services';
import { Browser } from '../../../services/browser';
import { CommonProps } from '../../common';
import { EuiI18n } from '../../i18n';

import {
EuiFormControlLayout,
Expand Down Expand Up @@ -256,36 +257,47 @@ export class EuiFieldSearchClass extends Component<
];

return (
<EuiFormControlLayout
icon="search"
fullWidth={fullWidth}
isLoading={isLoading}
isInvalid={isInvalid}
isDisabled={disabled}
clear={
isClearable
? { onClick: this.onClear, 'data-test-subj': 'clearSearchButton' }
: undefined
}
compressed={compressed}
append={append}
prepend={prepend}
<EuiI18n
token="euiFieldSearch.clearSearchButtonLabel"
default="Clear search input"
>
<EuiValidatableControl isInvalid={isInvalid}>
<input
type="search"
id={id}
name={name}
placeholder={placeholder}
className={classes}
css={cssStyles}
onKeyUp={(e) => this.onKeyUp(e, incremental, onSearch)}
disabled={disabled}
ref={this.setRef}
{...rest}
/>
</EuiValidatableControl>
</EuiFormControlLayout>
{(clearSearchButtonLabel: string) => (
<EuiFormControlLayout
icon="search"
fullWidth={fullWidth}
isLoading={isLoading}
isInvalid={isInvalid}
isDisabled={disabled}
clear={
isClearable
? {
onClick: this.onClear,
'aria-label': clearSearchButtonLabel,
'data-test-subj': 'clearSearchButton',
}
: undefined
}
compressed={compressed}
append={append}
prepend={prepend}
>
<EuiValidatableControl isInvalid={isInvalid}>
<input
type="search"
id={id}
name={name}
placeholder={placeholder}
className={classes}
css={cssStyles}
onKeyUp={(e) => this.onKeyUp(e, incremental, onSearch)}
disabled={disabled}
ref={this.setRef}
{...rest}
/>
</EuiValidatableControl>
</EuiFormControlLayout>
)}
</EuiI18n>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ exports[`SearchBar render - provided query, filters 1`] = `
class="euiFormControlLayoutIcons emotion-euiFormControlLayoutIcons-absolute-right"
>
<button
aria-label="Clear input"
aria-label="Clear search input"
class="euiFormControlLayoutClearButton emotion-euiFormControlLayoutClearButton"
data-test-subj="clearSearchButton"
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ exports[`EuiSelectable search value supports inheriting initialSearchValue from
class="euiFormControlLayoutIcons emotion-euiFormControlLayoutIcons-absolute-right"
>
<button
aria-label="Clear input"
aria-label="Clear search input"
class="euiFormControlLayoutClearButton emotion-euiFormControlLayoutClearButton"
data-test-subj="clearSearchButton"
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ exports[`EuiSelectableSearch renders placeholder, value, name, and other remaini
class="euiFormControlLayoutIcons emotion-euiFormControlLayoutIcons-absolute-right"
>
<button
aria-label="Clear input"
aria-label="Clear search input"
class="euiFormControlLayoutClearButton emotion-euiFormControlLayoutClearButton"
data-test-subj="clearSearchButton"
type="button"
Expand Down
Loading