Skip to content

Commit

Permalink
[EuiFieldSearch] update clear button aria-label (#7970)
Browse files Browse the repository at this point in the history
Co-authored-by: Cee Chen <[email protected]>
  • Loading branch information
alexwizp and cee-chen authored Aug 19, 2024
1 parent 9fcaaa0 commit da774cf
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 34 deletions.
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

0 comments on commit da774cf

Please sign in to comment.