Skip to content

Commit

Permalink
feat(responsive-nav): added aria-controls
Browse files Browse the repository at this point in the history
Added aria-controls and handler for click on navigation links to close menu
  • Loading branch information
alicegoarnisson committed Nov 27, 2024
1 parent b10f1d6 commit 7a91a53
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion addon/components/pix-navigation.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
>Menu</PixButton>
</div>
</header>
<nav class="pix-navigation__nav" aria-label={{@navigationAriaLabel}} id={{this.navigationId}}>
<nav
class="pix-navigation__nav"
{{on "click" this.handleNavigationClick}}
aria-label={{@navigationAriaLabel}}
id={{this.navigationId}}
>
{{yield to="navElements"}}
</nav>
<footer class="pix-navigation__footer" id={{this.footerId}}>{{yield to="footer"}}</footer>
Expand Down
7 changes: 7 additions & 0 deletions addon/components/pix-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ export default class PixMNavigation extends Component {
this.navigationMenuOpened = !this.navigationMenuOpened;
}

@action
handleNavigationClick(event) {
if (event.target.nodeName === 'A') {
this.navigationMenuOpened = false;
}
}

get navigationId() {
return `${this._navigationId}-nav`;
}
Expand Down

0 comments on commit 7a91a53

Please sign in to comment.