Skip to content

Commit 6c785d1

Browse files
authored
Merge pull request #348 from codesnippetspro/a11y-nav-tab-wrapper
Fix: accessible navigation tab wrappers
2 parents 3f59955 + 7ad1990 commit 6c785d1

6 files changed

Lines changed: 19 additions & 10 deletions

File tree

src/css/import/_page.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
max-inline-size: 800px;
44
}
55

6-
h2.nav-tab-wrapper {
6+
.nav-tab-wrapper {
77
margin-block-end: 20px;
88
}
99
}

src/css/manage.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
line-height: 1.4;
7878
}
7979

80-
.wrap h2.nav-tab-wrapper {
80+
.wrap .nav-tab-wrapper {
8181
.nav-tab {
8282
display: flex;
8383
flex-flow: row wrap;

src/js/components/ImportMenu/ImportMenu.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export const ImportMenu: React.FC = () => {
3737
<h1>{__('Import Snippets', 'code-snippets')}</h1>
3838

3939
<div className="narrow">
40-
<h2 className="nav-tab-wrapper">
40+
<nav
41+
className="nav-tab-wrapper"
42+
aria-label={__('Import sources', 'code-snippets')}
43+
>
4144
{TABS.map(tab =>
4245
<button
4346
key={tab}
@@ -50,7 +53,7 @@ export const ImportMenu: React.FC = () => {
5053
>
5154
{TAB_LABELS[tab]}
5255
</button>)}
53-
</h2>
56+
</nav>
5457

5558
<WithRestAPIContext>
5659
{TABS.map(tab =>

src/js/components/ManageMenu/CommunityCloud/CommunityCloud.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ export const CommunityCloud = () => {
2626
<div className="wrap">
2727
<h1>{__('Community Cloud', 'code-snippets')}</h1>
2828

29-
<h2 className="nav-tab-wrapper">
29+
<nav
30+
className="nav-tab-wrapper"
31+
aria-label={__('Community Cloud types', 'code-snippets')}
32+
>
3033
{TABS.map(tab =>
3134
<a
3235
key={tab}
@@ -46,7 +49,7 @@ export const CommunityCloud = () => {
4649
{TAB_LABELS[tab]}
4750
{PRO_TABS.includes(tab) && !isLicensed() && <span className="pro-chip">{__('Pro', 'code-snippets')}</span>}
4851
</a>)}
49-
</h2>
52+
</nav>
5053

5154
{'snippets' === currentTab
5255
? <WithRestAPIContext>

src/js/components/ManageMenu/SnippetsTable/SnippetsTable.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,14 @@ const SnippetsTableInner = () => {
121121
<div className="wrap">
122122
<PageHeading />
123123

124-
<h2 className="nav-tab-wrapper snippet-type-tabs">
124+
<nav
125+
className="nav-tab-wrapper snippet-type-tabs"
126+
aria-label={__('Snippet types', 'code-snippets')}
127+
>
125128
<SnippetTypeTab setIsUpgradeDialogOpen={setIsUpgradeDialogOpen} />
126129
{SNIPPET_TYPES.map(type =>
127130
<SnippetTypeTab key={type} type={type} setIsUpgradeDialogOpen={setIsUpgradeDialogOpen} />)}
128-
</h2>
131+
</nav>
129132

130133
<WithFilteredSnippetsContext>
131134
<SnippetsListTable />

src/php/Admin/Menus/Settings_Menu.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ protected function do_settings_tabs() {
254254
$sections = $this->get_sections();
255255
$active_tab = $this->get_current_section();
256256

257-
echo '<h2 class="nav-tab-wrapper" id="settings-sections-tabs">';
257+
echo '<nav class="nav-tab-wrapper" id="settings-sections-tabs" aria-label="' . esc_attr__( 'Settings tabs', 'code-snippets' ) . '">';
258258

259259
foreach ( $sections as $section ) {
260260
printf(
@@ -266,7 +266,7 @@ protected function do_settings_tabs() {
266266
);
267267
}
268268

269-
echo '</h2>';
269+
echo '</nav>';
270270

271271
foreach ( $sections as $section ) {
272272
if ( 'license' === $section['id'] ) {

0 commit comments

Comments
 (0)