File tree Expand file tree Collapse file tree 4 files changed +29
-0
lines changed
__tests__/components/__snapshots__ Expand file tree Collapse file tree 4 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77
88## [ Unreleased]
99
10+ ### Added
11+
12+ - Added label to search bar component for accessibility and CSS to hide the label on the screen.
13+
1014## [ 3.178.1] - 2025-04-14
1115
1216### Changed
Original file line number Diff line number Diff line change @@ -15,6 +15,13 @@ exports[`<SearchBar /> should match snapshot 1`] = `
1515 class = " relative-m w-100 searchBarInnerContainer"
1616 role = " combobox"
1717 >
18+ <label
19+ class = " visuallyHidden"
20+ for = " downshift-1-input"
21+ id = " downshift-1-label"
22+ >
23+ Search
24+ </label >
1825 <div
1926 class = " autoCompleteOuterContainer"
2027 >
@@ -24,6 +31,7 @@ exports[`<SearchBar /> should match snapshot 1`] = `
2431 <label >
2532 <input
2633 aria-autocomplete = " list"
34+ aria-label = " Search for products"
2735 aria-labelledby = " downshift-1-label"
2836 autocomplete = " off"
2937 data-error = " false"
Original file line number Diff line number Diff line change 3434 box-shadow : none;
3535 }
3636}
37+
38+ .visuallyHidden {
39+ border : 0 ;
40+ clip : rect (0 0 0 0 );
41+ clip-path : inset (50% );
42+ height : 1px ;
43+ margin : -1px ;
44+ overflow : hidden;
45+ padding : 0 ;
46+ position : absolute;
47+ white-space : nowrap;
48+ width : 1px ;
49+ }
Original file line number Diff line number Diff line change @@ -273,6 +273,7 @@ function SearchBar({
273273 getInputProps,
274274 getItemProps,
275275 getMenuProps,
276+ getLabelProps,
276277 selectedItem,
277278 highlightedIndex,
278279 isOpen,
@@ -285,6 +286,9 @@ function SearchBar({
285286 [ isOpen ? 'opened' : '' , inputValue ? 'filled' : '' ]
286287 ) } `}
287288 >
289+ < label { ...getLabelProps ( ) } className = { styles . visuallyHidden } >
290+ { formatIOMessage ( { id : placeholder , intl } ) as string }
291+ </ label >
288292 < AutocompleteInput
289293 // eslint-disable-next-line jsx-a11y/no-autofocus
290294 autoFocus = { autoFocus }
You can’t perform that action at this time.
0 commit comments