Skip to content

Reordering display navigation may be disorienting #3920

@aduth

Description

@aduth

As a user, I expect that the order of content in tab navigation and accessibility tree matches the visual presentation, so that I'm not disoriented by focus shifting unpredictably while navigating content (via Tab, for example).

As a developer, I expect that when I place content in markup after .usa-nav__primary, it will be shown visually after the navigation content.

An example of this is in the primary navigation mobile styling:

// Primary navigation
// ---------------------------------
.usa-nav__primary {
// Until the $theme-header-width,
// use the usa-nav-list styles for the slide-in nav
@include at-media-max($theme-header-min-width) {
@include nav-list("nav");
margin-top: units(3);
order: 2;

You can verify this by tabbing through the mobile navigation menu in the component demo, where you will find that:

  • Display order: Close button, search field, search button, menu links
  • Tab order: Close button, menu links, search field, search button

Interestingly, this problem does not affect the USWDS main website, since .usa-primary__nav is rendered within a (non-flex) .usa-nav__inner container.

Related guidance:

Related resources:

Possible improvements:

  • Update guidance to recommend two copies of the search form or menu items for mobile and desktop, where respectively the search field is shown prior to menu items (mobile) and after menu items (desktop).
  • Dynamically update DOM in JavaScript to reorder search field, optionally in combination with MediaQueryList#addListener to update after viewport size changes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions