Skip to content

Commit 3bae221

Browse files
Add aria-labels and accessibility improvements to buttons and navigation components
1 parent 283b1fc commit 3bae221

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

src/components/Banner/index.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { link, title } = entry.data;
99
<a class="banner-content" href={link} target="_blank">
1010
<Content />
1111
</a>
12-
<button id="hideBanner"><Icon kind="close"></button>
12+
<button id="hideBanner" aria-label="Hide banner"><Icon kind="close" /></button>
1313
</div>
1414

1515
<script>

src/components/Nav/JumpToLinks.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@ export const JumpToLinks = ({
2020
return (
2121
<div class={`${styles.jumpto} ${isOpen && "open"}`}>
2222
<button
23-
class={styles.toggle}
24-
onClick={handleToggle}
25-
aria-hidden="true"
26-
tabIndex={-1}
27-
>
28-
<span>{heading}</span>
29-
<div class="pt-[6px]">
30-
<Icon kind={isOpen ? "chevron-down" : "chevron-up"} />
31-
</div>
32-
</button>
23+
class={styles.toggle}
24+
onClick={handleToggle}
25+
aria-expanded={isOpen}
26+
aria-label={`${heading} menu toggle`}
27+
>
28+
<span>{heading}</span>
29+
<div class="pt-[6px]">
30+
<Icon kind={isOpen ? "chevron-down" : "chevron-up"} />
31+
</div>
32+
</button>
33+
3334
{isOpen && (
3435
<ul>
3536
{links?.map((link) => (

src/components/Nav/MainNavLinks.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,12 @@ export const MainNavLinks = ({
4343
</a>
4444

4545
<button
46-
class={styles.toggle}
47-
onClick={handleToggle}
48-
aria-hidden="true"
49-
tabIndex={-1}
50-
>
46+
class={styles.toggle}
47+
onClick={handleToggle}
48+
aria-expanded={isOpen}
49+
aria-label={mobileMenuLabel || "Toggle navigation menu"}
50+
>
51+
5152
<div class={styles.mobileMenuLabel}>
5253
{isOpen ? (
5354
<Icon kind="close" />

src/components/ReferenceDirectoryWithFilter/index.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,10 @@ export const ReferenceDirectoryWithFilter = ({
221221
}}
222222
/>
223223
{searchKeyword.length > 0 && (
224-
<button type="reset" class="" onClick={clearInput}>
225-
<Icon kind="close" className="h-4 w-4" />
226-
</button>
224+
<button type="reset" class="" onClick={clearInput} aria-label="Clear search input">
225+
<Icon kind="close" className="h-4 w-4" />
226+
</button>
227+
227228
)}
228229
</div>
229230
</div>

src/components/SearchResults/index.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ const SearchResults = ({
7777
value={category}
7878
className="capitalize"
7979
onClick={() => toggleFilter(category)}
80+
aria-pressed={currentFilter === category}
81+
aria-label={`Filter by ${uiTranslations[uiTranslationKey(category)]}`}
8082
>
8183
<div class="flex flex-nowrap gap-xs">
8284
{uiTranslations[uiTranslationKey(category)]}
@@ -131,6 +133,7 @@ const SearchResults = ({
131133
type="submit"
132134
class="absolute right-0 top-[2px] px-[22px] py-[13px]"
133135
onClick={submitInput}
136+
aria-label="Submit search"
134137
>
135138
<Icon kind="arrow-lg" />
136139
</button>
@@ -139,6 +142,7 @@ const SearchResults = ({
139142
type="reset"
140143
class="absolute right-0 top-0 px-[22px] py-[13px]"
141144
onClick={clearInput}
145+
aria-label="Clear search input"
142146
>
143147
<Icon kind="close-lg" />
144148
</button>

0 commit comments

Comments
 (0)