Skip to content
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Added

- Added label to search bar component for accessibility and CSS to hide the label on the screen.

## [3.178.1] - 2025-04-14

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ exports[`<SearchBar /> should match snapshot 1`] = `
class="relative-m w-100 searchBarInnerContainer"
role="combobox"
>
<label
class="visuallyHidden"
for="downshift-1-input"
id="downshift-1-label"
>
Search
</label>
<div
class="autoCompleteOuterContainer"
>
Expand All @@ -24,6 +31,7 @@ exports[`<SearchBar /> should match snapshot 1`] = `
<label>
<input
aria-autocomplete="list"
aria-label="Search for products"
aria-labelledby="downshift-1-label"
autocomplete="off"
data-error="false"
Expand Down
13 changes: 13 additions & 0 deletions react/components/SearchBar/SearchBar.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,16 @@
box-shadow: none;
}
}

.visuallyHidden {
border: 0;
clip: rect(0 0 0 0);
clip-path: inset(50%);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
white-space: nowrap;
width: 1px;
}
4 changes: 4 additions & 0 deletions react/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
/** Current value of the input */
inputValue: string
/** Function to handle input changes */
onInputChange: DownshiftProps<any>['onChange']

Check warning on line 43 in react/components/SearchBar/SearchBar.tsx

View workflow job for this annotation

GitHub Actions / Lint

Unexpected any. Specify a different type
/** Function to direct the user to the searchPage */
onGoToSearchPage: () => void
/** Function to clear the input */
Expand Down Expand Up @@ -273,6 +273,7 @@
getInputProps,
getItemProps,
getMenuProps,
getLabelProps,
selectedItem,
highlightedIndex,
isOpen,
Expand All @@ -285,6 +286,9 @@
[isOpen ? 'opened' : '', inputValue ? 'filled' : '']
)}`}
>
<label {...getLabelProps()} className={styles.visuallyHidden}>
{formatIOMessage({ id: placeholder, intl }) as string}
</label>
<AutocompleteInput
// eslint-disable-next-line jsx-a11y/no-autofocus
autoFocus={autoFocus}
Expand Down
Loading