-
Notifications
You must be signed in to change notification settings - Fork 934
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
[IDP] In-page navigation #4918
[IDP] In-page navigation #4918
Conversation
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
|
@mitchmoccia Starting to do some testing on appearance and behavior - it is working well so far! I had a few questions about alignment and am flagging some questions in the code comments. I will keep looking poking at it this afternoon and will cycle back tomorrow for more review. If you have any questions in the meantime, please let me know! |
| {% endif %} | ||
| </main> | ||
|
|
||
| <aside class="usa-in-page-nav"></aside> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mitchmoccia @mejiaj
Wondering about the benefits of nesting the <nav> inside an <aside>. I believe it is valid (depending on how it is defined), but feels semantically unnecessary and appears to just add an extra layer for users to tab through.
Can we just make this element the <nav> itself or switch to a <div> (if it needs a wrapper)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The HTML5 standard mentions [html.spec.whatwg.org]:
The element can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page.
And they have an example below (third example down):
TL;DR I can see both sides of the argument. Semantically I think it's okay. The final decision depends on the screen reader experience. Unless others understand the use case better, please chime in!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!
Something I noticed is that in the same spec, it does show this example for the nav element. https://html.spec.whatwg.org/multipage/sections.html#the-nav-element
In the following example, there are two nav elements, one for primary navigation around the site, and one for secondary navigation around the page itself.
FWIW: I did poke around at other implementations and found that in its own implementation of a similar component (The "In this article" TOC on the right), Mozilla uses an <aside> with a nested <section> and no <nav>: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside
Other popular design systems use <nav> with a nested list or just a <div> with a nested list.
So my tl;dr is that it seems like there are a lot of possible correct paths here regarding if it is a nav or aside (or both), and that it might just depend on how we define "tangential" or "indirectly related" content. Users should still be able to find what they need with either. Change would only be needed here if we want to remove an extra layer when users navigate by element, but it shouldn't affect users who tab into it.
The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content. Such sections are often represented as sidebars in printed typography.
The element can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of nav elements, and for other content that is considered separate from the main content of the page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the tag team analysis!! I did some quick testing in VoiceOver and it doesn't seem to make a difference... I did make the decision to use aside > nav based on the w3c example but will go with whatever makes most sense.
packages/uswds-core/src/styles/settings/_settings-components.scss
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice rewrite @mitchmoccia! The code, but JS especially looks much more in-line with other component standards.
Added some comments and suggestions. Also, I'm sure you've got this in mind already, but I didn't notice any unit tests for this component.
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
| }, | ||
| keydown: { | ||
| [IN_PAGE_NAV_LINK]: keymap({ | ||
| Enter: handleEnterFromLink, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triggering via spacebar might also be a good idea, not a requirement though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's consider this as a possible followup enhancement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created issue #5021.
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/uswds-core/src/styles/settings/_settings-components.scss
Outdated
Show resolved
Hide resolved
packages/uswds-core/src/styles/settings/_settings-components.scss
Outdated
Show resolved
Hide resolved
|
Amazing feedback @amyleadem and @mejiaj THANK YOU... I'll be addressing all of these ASAP |
…page-nav class to prevent appendChild errors on pages that dont have it
… the nav before content when tabbing through the page
|
@thisisdano @mejiaj @amyleadem Just made a great update per Dan's suggestion... The in-page nav heading text and heading level are now customizable from the HTML via data attributes! The new attributes are data-title and data-heading-level both added to the aside element. I have also updated the unit tests and everything is looking good. Let me know how it looks on your end, thanks! |
…s are not present
|
I added two variables const and then check for the presence of the corresponding data attributes and if none, use the defaults... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some great improvements here! Added some comments and questions.
I tested the for:
- ANDI a11y plugin - no errors
- AXE plugin - no errors
- Checked display on site - minor with empty
<p></p> - Checked output HTML of component - minor with empty
<p></p> - Tested custom data attributes for heading
- Reviewed JS for issues and possible improvements
- SASS formatting and possible improvements
- Ran NPM test - It seems only
in-pagenav tests ran
Seeing the same in CircleCI build.

packages/usa-in-page-navigation/src/usa-in-page-navigation.twig
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
packages/usa-in-page-navigation/src/styles/_usa-in-page-navigation.scss
Outdated
Show resolved
Hide resolved
Co-authored-by: James Mejia <james.mejia@gsa.gov>
…tion.scss Co-authored-by: James Mejia <james.mejia@gsa.gov>
Co-authored-by: James Mejia <james.mejia@gsa.gov>
…tion.scss Co-authored-by: James Mejia <james.mejia@gsa.gov>
Addressed changes



This is a follow-up PR for In-page navigation from this earlier PR:
#4860
https://federalist-3b6ba08e-0df4-44c9-ac73-6fc193b0e19c.app.cloud.gov/preview/uswds/uswds/mm-in-page-nav4/?path=/story/components-in-page-navigation--default
This version addresses all the great comments left by @mejiaj. Looking forward to any and all feedback, thank you!