Skip to content

Commit 2bacf0e

Browse files
authored
Merge pull request #1807 from NYPL/DSD-1901/remove-role-search
DSD-1901: Remove `role="search"` from `Searchbar`
2 parents 7768adf + 52665f0 commit 2bacf0e

File tree

7 files changed

+23
-24
lines changed

7 files changed

+23
-24
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Currently, this repo is in Prerelease. When it is released, this project will ad
3838
- `StatusBadge`'s "low", "medium", "high" values from `statusBadgeTypeArray`
3939
- `StatusBadge`'s `level` prop
4040
- `StyledList`'s "tag", "mini" values in `textSizesArray`
41+
- Removes `role="search"` from `Searchbar` wrapper.
4142

4243
## Prerelease
4344

src/components/Banner/Banner.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { changelogData } from "./bannerChangelogData";
2121

2222
## Table of Contents
2323

24-
- {<Link href="#overiew" target="_self">Overview</Link>}
24+
- {<Link href="#overview" target="_self">Overview</Link>}
2525
- {<Link href="#component-props" target="_self">Component Props</Link>}
2626
- {<Link href="#accessibility" target="_self">Accessibility</Link>}
2727
- {<Link href="#variants" target="_self">Variants</Link>}

src/components/SearchBar/SearchBar.mdx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { ArgTypes, Canvas, Description, Meta, Source } from "@storybook/blocks";
22
import ComponentChangelogTable from "../../utils/ComponentChangelogTable";
3+
import ComponentDocsHeader from "../../utils/components/ComponentDocsHeader";
34
import { changelogData } from "./searchBarChangelogData";
45

56
import * as SearchBarStories from "./SearchBar.stories";
67
import Link from "../Link/Link";
78

89
<Meta of={SearchBarStories} />
910

10-
# SearchBar
11+
<ComponentDocsHeader
12+
category="Form element"
13+
componentName="SearchBar"
14+
summary="A form container with text input and button that submits a search query"
15+
versionAdded="0.0.4"
16+
versionLatest="Prerelease"
17+
/>
1118

12-
| Component Version | DS Version |
13-
| ----------------- | ---------- |
14-
| Added | `0.0.4` |
15-
| Latest | `3.6.1` |
19+
<Canvas of={SearchBarStories.WithControls} />
1620

1721
## Table of Contents
1822

@@ -54,8 +58,9 @@ aria-labels are used to make these children components accessible.
5458
The `SearchBar` component is implemented with Reservoir `Select`, `TextInput`,
5559
and `Button` accessible components. This a "complete" component that renders an
5660
HTML `<form>` element that is submitted with a `<button>` element of `type="submit"`.
57-
The `<form>` element also has a `role="search"` attribute that allows
58-
screenreaders to pick up this entire search form.
61+
62+
The `Searchbar`, along with any other search/filter functionality, must be wrapped in a container with role="search", for a screenreader to recognize it correctly.
63+
See [search in "ARIA Landmarks"](../?path=/docs/accessibility-guide-aria-landmarks--docs#search).
5964

6065
Resources:
6166

src/components/SearchBar/SearchBar.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ describe("SearchBar", () => {
101101
textInputProps={textInputProps}
102102
/>
103103
);
104-
expect(screen.getByRole("search")).toBeInTheDocument();
105-
expect(screen.getByRole("search")).toHaveAttribute(
104+
expect(screen.getByRole("form")).toBeInTheDocument();
105+
expect(screen.getByRole("form")).toHaveAttribute(
106106
"aria-label",
107107
`${labelText} - ${helperText}`
108108
);

src/components/SearchBar/SearchBar.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ export const SearchBar: ChakraComponent<
242242
as="form"
243243
id={`searchbar-form-${id}`}
244244
className={className}
245-
role="search"
246245
aria-label={finalAriaLabel}
247246
onSubmit={onSubmit}
248247
method={method}

src/components/SearchBar/__snapshots__/SearchBar.test.tsx.snap

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ exports[`SearchBar renders the UI snapshot correctly 1`] = `
1010
className="css-1xdhyk6"
1111
id="searchbar-form-basic"
1212
onSubmit={[MockFunction]}
13-
role="search"
1413
>
1514
<div
1615
className="css-1ik4laa"
@@ -91,7 +90,6 @@ exports[`SearchBar renders the UI snapshot correctly 2`] = `
9190
className="css-1xdhyk6"
9291
id="searchbar-form-withSelect"
9392
onSubmit={[MockFunction]}
94-
role="search"
9593
>
9694
<div
9795
className="css-1u8qly9"
@@ -269,7 +267,6 @@ exports[`SearchBar renders the UI snapshot correctly 3`] = `
269267
className="css-1xdhyk6"
270268
id="searchbar-form-withoutHelperText"
271269
onSubmit={[MockFunction]}
272-
role="search"
273270
>
274271
<div
275272
className="css-1ik4laa"
@@ -333,7 +330,6 @@ exports[`SearchBar renders the UI snapshot correctly 4`] = `
333330
className="css-1xdhyk6"
334331
id="searchbar-form-withClearButton"
335332
onSubmit={[MockFunction]}
336-
role="search"
337333
>
338334
<div
339335
className="css-1ik4laa"
@@ -414,7 +410,6 @@ exports[`SearchBar renders the UI snapshot correctly 5`] = `
414410
className="css-1xdhyk6"
415411
id="searchbar-form-invalidState"
416412
onSubmit={[MockFunction]}
417-
role="search"
418413
>
419414
<div
420415
className="css-1ik4laa"
@@ -487,7 +482,6 @@ exports[`SearchBar renders the UI snapshot correctly 6`] = `
487482
className="css-1xdhyk6"
488483
id="searchbar-form-disabledState"
489484
onSubmit={[MockFunction]}
490-
role="search"
491485
>
492486
<div
493487
className="css-1ik4laa"
@@ -552,7 +546,6 @@ exports[`SearchBar renders the UI snapshot correctly 7`] = `
552546
className="css-1xdhyk6"
553547
id="searchbar-form-requiredState"
554548
onSubmit={[MockFunction]}
555-
role="search"
556549
>
557550
<div
558551
className="css-1ik4laa"
@@ -618,7 +611,6 @@ exports[`SearchBar renders the UI snapshot correctly 8`] = `
618611
className="css-1xdhyk6"
619612
id="searchbar-form-noBrandButtonType"
620613
onSubmit={[MockFunction]}
621-
role="search"
622614
>
623615
<div
624616
className="css-1ik4laa"
@@ -690,7 +682,6 @@ exports[`SearchBar renders the UI snapshot correctly 9`] = `
690682
className="css-1xdhyk6"
691683
id="searchbar-form-withHeading"
692684
onSubmit={[MockFunction]}
693-
role="search"
694685
>
695686
<div
696687
className="css-1ik4laa"
@@ -735,7 +726,6 @@ exports[`SearchBar renders the UI snapshot correctly 10`] = `
735726
className="css-1xdhyk6"
736727
id="searchbar-form-withDescription"
737728
onSubmit={[MockFunction]}
738-
role="search"
739729
>
740730
<div
741731
className="css-1ik4laa"
@@ -786,7 +776,6 @@ exports[`SearchBar renders the UI snapshot correctly 11`] = `
786776
className="css-1xdhyk6"
787777
id="searchbar-form-withHeadingAndDescription"
788778
onSubmit={[MockFunction]}
789-
role="search"
790779
>
791780
<div
792781
className="css-1ik4laa"
@@ -826,7 +815,6 @@ exports[`SearchBar renders the UI snapshot correctly 12`] = `
826815
className="css-kle7zy"
827816
id="searchbar-form-chakra"
828817
onSubmit={[MockFunction]}
829-
role="search"
830818
>
831819
<div
832820
className="css-1ik4laa"
@@ -908,7 +896,6 @@ exports[`SearchBar renders the UI snapshot correctly 13`] = `
908896
className="css-1xdhyk6"
909897
id="searchbar-form-props"
910898
onSubmit={[MockFunction]}
911-
role="search"
912899
>
913900
<div
914901
className="css-1ik4laa"

src/components/SearchBar/searchBarChangelogData.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
import { ChangelogData } from "../../utils/ComponentChangelogTable";
1010

1111
export const changelogData: ChangelogData[] = [
12+
{
13+
date: "Prerelease",
14+
version: "Prerelease",
15+
type: "Update",
16+
affects: ["Accessibility", "Documentation"],
17+
notes: ["Removes role=search on the component wrapper."],
18+
},
1219
{
1320
date: "2025-04-24",
1421
version: "3.6.1",

0 commit comments

Comments
 (0)