Skip to content

Conversation

mitchmoccia
Copy link
Contributor

@mitchmoccia mitchmoccia commented Feb 3, 2023

This guidance update supports PR 5124 which changes the main content section requirement for in-page nav from the main element to any element with the class .usa-in-page-nav__main.
uswds/uswds#5124

https://federalist-ead78f8d-8948-417c-a957-c21ec5617a57.sites.pages.cloud.gov/preview/uswds/uswds-site/mm-in-page-nav-guidance/components/in-page-navigation/

A changelog entry has been made as well. Thanks for your review!

@amyleadem amyleadem self-assigned this Feb 3, 2023
Copy link
Contributor

@amyleadem amyleadem left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mitchmoccia
Thanks for your work here. I added some suggestions in the comments for your review. Some are small single word fixes, others are slightly larger structural recommendations. There might be reasoning for the existing structure that I am not aware of -- if so, feel free to take or leave my recommendations. I also understand if some of these items are creeping out of scope. If you have any questions, please don't hesitate to reach out.

@@ -1,5 +1,5 @@
- **Allow keyboard navigation.** Users should be able to navigate between nav items by using the `Tab` key. They should also be able to activate a link when pressing `Enter` on their keyboard. Users should be able to activate hover and focus states with both a mouse and a keyboard.

- **Enable tab order so keyboard users access the in-page navigation before the main content section.** When a user tabs through a page that contains the in-page navigation component, they should find the in-page navigation before the `main` content. Since the in-page nav will most commonly exist to the right of the content (and follows the `main` element in the markup) this may seem like a tab-order error, but tabbing through the entire page before getting to in-page navigation links is not logical, creates confusion, and diminishes the user experience.
- **Enable tab order so keyboard users access the in-page navigation before the main content section.** When a user tabs through a page that contains the in-page navigation component, they should find the in-page navigation links before the main content. The in-page nav will most commonly exist to the right of the content, yet in the markup, precede the `.usa-in-page-nav__main` element. This may seem like a tab-order error, but this prevents tabbing through the entire page before getting to the in-page navigation links, which is not logical, creates confusion, and diminishes the user experience.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The phrase "Enable tab order" felt confusing to me. I made a few suggestions in an effort to add clarity and shorten the text a bit. Take what you will!

Suggested change
- **Enable tab order so keyboard users access the in-page navigation before the main content section.** When a user tabs through a page that contains the in-page navigation component, they should find the in-page navigation links before the main content. The in-page nav will most commonly exist to the right of the content, yet in the markup, precede the `.usa-in-page-nav__main` element. This may seem like a tab-order error, but this prevents tabbing through the entire page before getting to the in-page navigation links, which is not logical, creates confusion, and diminishes the user experience.
- **Consider tab order.** Structure your markup so that keyboard users can access the in-page navigation _before_ the main content section. The in-page navigation will most commonly exist to the right of the content, but should come before the `.usa-in-page-nav__main` element in the markup. This may seem like a tab order error, but it allows keyboard users to find navigation items sooner, which is more logical and minimizes confusion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the requested changes on accessibility and clarified tab order.

Comment on lines 19 to +22
- **Root margin.** The root margin property (`data-root-margin`) is a string that allows you to define the observable area. This set of values grows or shrinks the observable area from each side of the root element's bounding box before computing intersections. It can accept values similar to the CSS margin property, and can be percentages. By default, the in-page navigation component is set to `0px 0px 0px 0px`.
- **Threshold.** The threshold property (`data-threshold`) determines how much of the observable section must be present in the observed area before the nav's item is set to current. The default is `1`, which means 100% of the observables must be in the observed section. You can set `data-threshold` to any integer between 0 and 1.

{:.usa-content-list }
- **Threshold.** The threshold property (`data-threshold`) determines how much of the observable section must be present in the observed area before the nav's item is set to current. The default is `1`, which means 100% of the observables must be in the observed section. You can set `data-threshold` to any decimal value between 0 and 1. For example, `threshold: .5` would require that 50% of the observable section is visible in the observed section before the navigation item is set to `current`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to condense this property-related content (e.g. the summaries for threshold and root margin) into their related descriptions in the properties table? It feels a little confusing to me that similar/overlapping information about these properties is found in two separate areas on the page.

Comment on lines 2 to 16
Implementing the in-page navigation component requires a few additions and adjustments to your page's markup.

{:.usa-content-list }
- A wrapper `div` with the class `usa-in-page-nav-container` must surround the `main` element of your page.
- A new sibling `aside` with the class `usa-in-page-nav` must precede the `main` element.
- A wrapper `div` with the class `.usa-in-page-nav` must surround the `aside` element with the class `.usa-in-page-nav__container` and be followed by a sibling element (e.g. `div`) with the class `.usa-in-page-nav__main`.

The following is an example of the minimum markup your page would need to inplement the in-page navigation component:

```
<div class="usa-in-page-nav-container">
<aside class="usa-in-page-nav"></aside>
<main id="main-content" class="main-content">
<div class="usa-in-page-nav">
<aside class="usa-in-page-nav__container"></aside>
<div class="usa-in-page-nav__main">
[ Page content ]
</main>
</div>
</div>
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a formatting issue that caused the content in this section to visually extend beyond the width of usa-content-list content. Additionally, there are a couple opportunities to standardize content structure. I added a suggestion for lines 2-16 below that:

  1. Adds a bolded summary for the section
  2. Combines related content into one list item
  3. Fixes formatting issues.
- **Structure your markup.** Implementing the in-page navigation component requires a few additions and adjustments to your page's markup.
    A wrapper `div` with the class `usa-in-page-nav-container` must surround the `main` element of your page.
    A new sibling `aside` with the class `usa-in-page-nav` must precede the `main` element.
    The following is an example of the minimum markup your page would need to implement the in-page navigation component:

    ```html
    <div class="usa-in-page-nav">
      <aside class="usa-in-page-nav__container"></aside>
      <div class="usa-in-page-nav__main">
        [ Page content ]
      </div>
    </div>
    ```

Comment on lines 17 to 18

{:.usa-content-list }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should need only one declaration of {:.usa-content-list }. It should be safe to remove this and the other declarations below. As long as there is no unnecessary space between the list items, it should be format correctly.

Suggested change
{:.usa-content-list }

@@ -2,6 +2,17 @@ title: In-page navigation
type: component
changelogURL:
items:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you add a changelog item that explains the changes made to the uswds-site repo in this PR? It might feel a bit redundant but I like the consistency of letting users have quick access to more context about the documentation updates if desired.

@@ -2,6 +2,17 @@ title: In-page navigation
type: component
changelogURL:
items:
- date: 2023-02-03
summary: Component updated to allow for any element to be used as the main content section.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a small structure shift. Changelog entries should begin with an active verb and provide the name of the component for added clarity.

Suggested change
summary: Component updated to allow for any element to be used as the main content section.
summary: Updated in-page navigation to allow for any element to be used as the main content section.

@@ -1,6 +1,6 @@
- **Make it stand out.** Site visitors should be able to quickly and easily distinguish in-page navigation from other landmarks on the page. Include borders and well-defined link active states to clearly convey the utility and purpose of the section. Define a consistent width for the in-page navigation component that is sufficiently wide and does not change based on text length.

- **Use language that matches section headings.** The text of the links displayed within the in-page navigation `aside` should match the heading text of the target sections. Our component scans the page for `h2` and `h3` elements within the `main` element, automatically creates the in-page navigation block, and dynamically inserts the text to match the section headings.
- **Use language that matches section headings.** The text of the links displayed within the in-page navigation `aside` should match the heading text of the target sections. Our component scans the page for `h2` and `h3` elements within the element that contains the class `.usa-in-page-nav__main`, automatically creates the in-page navigation block, and dynamically inserts the text to match the section headings.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opportunity to be slightly more direct

Suggested change
- **Use language that matches section headings.** The text of the links displayed within the in-page navigation `aside` should match the heading text of the target sections. Our component scans the page for `h2` and `h3` elements within the element that contains the class `.usa-in-page-nav__main`, automatically creates the in-page navigation block, and dynamically inserts the text to match the section headings.
- **Use language that matches section headings.** The text of the links displayed within the in-page navigation `aside` should match the heading text of the target sections. Our component scans the page for `h2` and `h3` elements within the `.usa-in-page-nav__main` element, automatically creates the in-page navigation block, and dynamically inserts the text to match the section headings.

affectsStyles: true
githubRepo: uswds
githubPr: 5124
versionUswds: 3.3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Before merge, the version and date will need to be updated for this changelog item

@@ -1,6 +1,6 @@
- **Make it stand out.** Site visitors should be able to quickly and easily distinguish in-page navigation from other landmarks on the page. Include borders and well-defined link active states to clearly convey the utility and purpose of the section. Define a consistent width for the in-page navigation component that is sufficiently wide and does not change based on text length.

- **Use language that matches section headings.** The text of the links displayed within the in-page navigation `aside` should match the heading text of the target sections. Our component scans the page for `h2` and `h3` elements within the `main` element, automatically creates the in-page navigation block, and dynamically inserts the text to match the section headings.
- **Use language that matches section headings.** The text of the links displayed within the in-page navigation `aside` should match the heading text of the target sections. Our component scans the page for `h2` and `h3` elements within the element that contains the class `.usa-in-page-nav__main`, automatically creates the in-page navigation block, and dynamically inserts the text to match the section headings.

- **Don't include the page `h1` in the nav.** Each page should have a single `h1` to describe its contents. It would be redundant to include this heading level in the in-page navigation.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change "nav" to "navigation".

Suggested change
- **Don't include the page `h1` in the nav.** Each page should have a single `h1` to describe its contents. It would be redundant to include this heading level in the in-page navigation.
- **Don't include the page `h1` in the navigation.** Each page should have a single `h1` to describe its contents. It would be redundant to include this heading level in the in-page navigation.

@amyleadem amyleadem removed their assignment Feb 6, 2023
Spell out navigation (was "nav" in several places). Clarify tab order.
@thisisdano thisisdano added this to the uswds 3.5.0 milestone Mar 7, 2023
@mejiaj
Copy link
Contributor

mejiaj commented Aug 7, 2023

@amyleadem is this PR still relevant or should we close and move to a new PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants