From 7fca59fb386f0463f7b120e2965807f1d23eea86 Mon Sep 17 00:00:00 2001 From: iRohitSingh <61353484+iRohitSingh@users.noreply.github.com> Date: Tue, 13 Feb 2024 20:29:26 +0530 Subject: [PATCH] Fix A11y in Navigation (#344) --- acceptance/cypress/tests/main/nav.cy.js | 8 +-- news/289.bugfix | 1 + src/components/Navigation/Navigation.jsx | 72 ++++++++++-------------- src/theme/_header.scss | 17 ++---- 4 files changed, 39 insertions(+), 59 deletions(-) create mode 100644 news/289.bugfix diff --git a/acceptance/cypress/tests/main/nav.cy.js b/acceptance/cypress/tests/main/nav.cy.js index ee26daf3..0f8e518a 100644 --- a/acceptance/cypress/tests/main/nav.cy.js +++ b/acceptance/cypress/tests/main/nav.cy.js @@ -27,7 +27,6 @@ context('Navigation Acceptance Tests', () => { path: '/level-1/level-2', }); - cy.visit('/'); cy.viewport('macbook-16'); }); @@ -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'); - }); }); - - - diff --git a/news/289.bugfix b/news/289.bugfix new file mode 100644 index 00000000..ffd81190 --- /dev/null +++ b/news/289.bugfix @@ -0,0 +1 @@ +Fix Navigation fails html validator due to use of divs inside ul tag @iRohitSingh \ No newline at end of file diff --git a/src/components/Navigation/Navigation.jsx b/src/components/Navigation/Navigation.jsx index 3b9e6e26..17a4723a 100644 --- a/src/components/Navigation/Navigation.jsx +++ b/src/components/Navigation/Navigation.jsx @@ -141,58 +141,48 @@ const Navigation = ({ pathname }) => { {item.items && item.items.length > 0 && item.items.map((subitem) => ( -
-
  • - closeMenu()} - className={cx({ - current: isActive(subitem.url), - })} - > - - - {subitem.nav_title || subitem.title} - - -
  • +
  • + closeMenu()} + className={cx({ + current: isActive(subitem.url), + })} + > + + + {subitem.nav_title || subitem.title} + +
      {subitem.items && subitem.items.length > 0 && subitem.items.map((subsubitem) => ( -
      -
    • - closeMenu()} - className={cx({ - current: isActive( - subsubitem.url, - ), - })} - > - - — - - - - {subsubitem.nav_title || - subsubitem.title} - - -
    • -
      + closeMenu()} + className={cx({ + current: isActive(subsubitem.url), + })} + > + + — + + + {subsubitem.nav_title || + subsubitem.title} + + + ))}
    -
  • + ))} diff --git a/src/theme/_header.scss b/src/theme/_header.scss index ed8872d6..63677734 100644 --- a/src/theme/_header.scss +++ b/src/theme/_header.scss @@ -409,6 +409,7 @@ body.has-toolbar.has-sidebar { color: $white; a { + padding-bottom: 0; font-size: 14px; font-weight: 400; line-height: 18px; @@ -490,12 +491,7 @@ body.has-toolbar.has-sidebar { } } - li { - position: relative; - padding-top: 0; - } - - li a.current { + a.current { .left-arrow { visibility: visible; } @@ -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 {