Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix A11y in Navigation #344

Merged
merged 2 commits into from
Feb 13, 2024
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
8 changes: 1 addition & 7 deletions acceptance/cypress/tests/main/nav.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ context('Navigation Acceptance Tests', () => {
path: '/level-1/level-2',
});


cy.visit('/');
cy.viewport('macbook-16');
});
Expand All @@ -44,17 +43,12 @@ context('Navigation Acceptance Tests', () => {
cy.get('ul.desktop-menu button').contains('Level 1').click();
cy.get('.subitem-wrapper').findByText('Level 2').click();
cy.get('.documentFirstHeading').should('have.text', 'Level 2');

});

it('Open 3rd level', function () {
cy.wait('@content');
cy.get('ul.desktop-menu button').contains('Level 1').click();
cy.get('.subsubitem-wrapper li').findByText('Level 3').click();
cy.get('.subsubitem-wrapper').findByText('Level 3').click();
cy.get('.documentFirstHeading').should('have.text', 'Level 3');

});
});



1 change: 1 addition & 0 deletions news/289.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix Navigation fails html validator due to use of divs inside ul tag @iRohitSingh
72 changes: 31 additions & 41 deletions src/components/Navigation/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,58 +141,48 @@ const Navigation = ({ pathname }) => {
{item.items &&
item.items.length > 0 &&
item.items.map((subitem) => (
<div
className="subitem-wrapper"
key={subitem.url}
>
<li key={subitem.url}>
<NavLink
to={subitem.url}
onClick={() => closeMenu()}
className={cx({
current: isActive(subitem.url),
})}
>
<span className="left-arrow">&#8212;</span>
<span>
{subitem.nav_title || subitem.title}
</span>
</NavLink>
</li>
<li className="subitem-wrapper" key={subitem.url}>
<NavLink
to={subitem.url}
onClick={() => closeMenu()}
className={cx({
current: isActive(subitem.url),
})}
>
<span className="left-arrow">&#8212;</span>
<span>
{subitem.nav_title || subitem.title}
</span>
</NavLink>
<div className="sub-submenu">
<ul>
{subitem.items &&
subitem.items.length > 0 &&
subitem.items.map((subsubitem) => (
<div
<li
className="subsubitem-wrapper"
key={subsubitem.url}
>
<li key={subsubitem.url}>
<NavLink
to={subsubitem.url}
onClick={() => closeMenu()}
className={cx({
current: isActive(
subsubitem.url,
),
})}
>
<span className="left-arrow">
&#8212;
</span>

<span>
{subsubitem.nav_title ||
subsubitem.title}
</span>
</NavLink>
</li>
</div>
<NavLink
to={subsubitem.url}
onClick={() => closeMenu()}
className={cx({
current: isActive(subsubitem.url),
})}
>
<span className="left-arrow">
&#8212;
</span>
<span>
{subsubitem.nav_title ||
subsubitem.title}
</span>
</NavLink>
</li>
))}
</ul>
</div>
</div>
</li>
))}
</ul>
</div>
Expand Down
17 changes: 6 additions & 11 deletions src/theme/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ body.has-toolbar.has-sidebar {
color: $white;

a {
padding-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 18px;
Expand Down Expand Up @@ -490,12 +491,7 @@ body.has-toolbar.has-sidebar {
}
}

li {
position: relative;
padding-top: 0;
}

li a.current {
a.current {
.left-arrow {
visibility: visible;
}
Expand All @@ -513,14 +509,13 @@ body.has-toolbar.has-sidebar {
display: flex;
}

li {
padding: 8px 0;
}

li a {
a {
position: relative;
display: inline-flex;
align-items: flex-start;
padding-bottom: 8px;
color: $black;

@include body-text-bold();

span {
Expand Down
Loading