Skip to content

USWDS - Header: Search input appears last in menu for mobile header. #6037

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

Merged
merged 13 commits into from
Oct 3, 2024

Conversation

cathybaptista
Copy link
Contributor

@cathybaptista cathybaptista commented Aug 27, 2024

Summary

Removed the CSS order property from mobile header navigation. Now, the visual order of the component matches the tab order.

Details

This change visually moves the search bar to appear last in the list of menu items in the mobile header. This change results in the header being compliant with WCAG criterion 2.4.3 (Focus order) in mobile view.

Breaking change

⚠️ This is a breaking change.

This change causes the search bar to appear at the bottom of the menu. If you would like to visually keep the search bar at the top of the menu, you will need to reorder your markup in the mobile view.

Related issue

Closes #5971, closes #3526, closes #3920.

Related pull requests

Changelog uswds/uswds-site#2798

Preview link

Preview link: Header Component

Problem statement

Summarize the problem this PR solves in a clear and concise statement.

Web pages should be able to be navigated in an order that preserves meaning and operability. Currently, the tab order in the mobile header menu does not match the visual order. Therefore, the component does not meet WCAG criterion 2.4.3 (Focus order).

Solution

By removing the order: 2; style from .usa-nav__primary, the search bar appears at the bottom of the menu in the mobile header, maintaining tab order and preserving meaning. This approach was chosen based on a conversation in dev sync on 8/6/24. This will impact users that wish to visually keep the search bar at the top of the menu; these users will need to reorder their markup in the mobile view.

Testing and review

  1. In Storybook, select the header component.
  2. Resize the browser to minimum width so that the menu is collapsed.
  3. Select the "menu" button and validate that the search input field appears after other sample links in the menu.
  4. Confirm the tab order is appropriate and consistent for each of the header variants.

I am looking for confirmation that the tab order makes sense and that it is consistent with WCAG criterion 2.4.3 (Focus order),

  • Confirm that this code follows the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run git pull origin [base branch] to pull in the most recent updates from your base and check for merge conflicts. (Often, the base branch is develop).
  • Run npm run prettier:sass to format any Sass updates.
  • Run npm test and confirm that all tests pass.
  • Run your code through HTML_CodeSniffer and make sure it’s error free.

@cathybaptista cathybaptista changed the title USWDS - Header: Search input appears at end of menu items. USWDS - Header: Search input last in menu. Aug 29, 2024
@cathybaptista cathybaptista changed the title USWDS - Header: Search input last in menu. USWDS - Header: Search input appears last in menu for mobile header. Aug 29, 2024
@cathybaptista cathybaptista marked this pull request as ready for review August 29, 2024 18:29
Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

Thanks @cathybaptista! The headers are looking consistent across the board.

One minor change to add an empty line before the anchor declaration

mahoneycm
mahoneycm previously approved these changes Sep 3, 2024
Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

Lgtm!

  • Header search placement is consistent across variants
  • Tab order matches expectation

Important

We'll want to mark this change our release notes. If we offer the suggestion to reapply order via CSS, we should flag that it goes against accessibility guidelines.

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.

Thanks for this work @cathybaptista! I confirmed that the tab order now matches the visual order.

I noticed that the vertical margins between mobile nav elements are a bit different across variants. Can you update the margins in the Default variant above the search bar and primary navigation to align with the margins in the Extended megamenu variant? I've highlighted the differences in the screenshot below:

image

@cathybaptista
Copy link
Contributor Author

Hi, @amyleadem!

2785b67 resolves spacing above the search bar

and

3a6c114 resolves spacing.

Thank you SO MUCH for all of your help with this!
:)
Cathy

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.

Thanks @cathybaptista.

I noticed that there is still a difference in the spacing between the search bar and link list. The basic variant has a margin-top of .5rem while the extended has a margin-top of 1rem.

Instead of the changes you made to usa-header.scss, I'm wondering if we can use the margin-top rule from .usa-nav__secondary .usa-search (line 342 of usa-nav.scss) and make it so that it applies more generically (potentially line 113 of the same file). Curious what you think!

@cathybaptista cathybaptista force-pushed the cb-remove-order-from-usa-nav branch from 3a6c114 to 7e420b6 Compare September 11, 2024 16:46
@cathybaptista
Copy link
Contributor Author

@amyleadem, I think this is a great idea! Ensures the top margin is consistent. :) check out 7e420b6 and http://localhost:6006/?path=/story/components-header--extended

@amyleadem amyleadem dismissed mahoneycm’s stale review September 11, 2024 21:27

Changes have been made since approval. Needs re-review.

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.

Looks good to me! Thanks @cathybaptista

@mahoneycm I am clearing your review since some changes have been made since you last saw it. Can you take another look when you get a moment?

Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

I noticed a regression in desktop views! Would you mind looking into this?

@aduth
Copy link
Contributor

aduth commented Sep 17, 2024

Does this fix #3920 and/or #3526?

@mahoneycm
Copy link
Contributor

@aduth it looks like it!

Copy link
Contributor

@mahoneycm mahoneycm left a comment

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

@cathybaptista nice job.

Functionally, everything looks and works well. Tested on both mobile and desktop breakpoints. No issues found with tabbing. One minor note to confirm on the header margin — I can approve once confirmed.

I've also updated the PR description to link the other issues that this feature closes.

- Closes #5971
+ Closes #5971, closes #3526, closes #3920.

Thanks for flagging that @aduth.

@@ -150,7 +151,7 @@ $z-index-overlay: 400;
.usa-nav {
@include u-flex("row", "align-center", "justify-end");
display: flex;
padding: 0 0 units(0.5) units(1);
padding: 0 0 units(1) units(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

thought: The clarity of this is nice. We can shorthand, but this approach seems better.

Copy link
Contributor

@mejiaj mejiaj left a comment

Choose a reason for hiding this comment

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

I was able to successfully test and confirm that the search input appears last.

I compared the feature branch with what's currently on develop. Before/after links below.

Before After
Develop Feature branch

@mejiaj mejiaj requested review from heymatthenry and thisisdano and removed request for RachelCorsino September 25, 2024 16:47
Copy link
Contributor

@thisisdano thisisdano left a comment

Choose a reason for hiding this comment

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

This one is probably technically a breaking change because of the UX and design implications — but it might be worth noting that I don't believe teams will have to make any changes to their code to make this work, so change does not introduce a breaking change on the code side

@thisisdano
Copy link
Contributor

I approve this PR, but we may want to double-check the changelog entry and release notes.

@amyleadem
Copy link
Contributor

@thisisdano Added a suggestion to the changelog in an attempt to clarify the user action for the breaking change here. Once we figure out a solution in the changelog, we can include the changelog in the release notes and PR description.

@thisisdano thisisdano merged commit c970584 into develop Oct 3, 2024
5 checks passed
@thisisdano thisisdano deleted the cb-remove-order-from-usa-nav branch October 3, 2024 16:13
@thisisdano thisisdano mentioned this pull request Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants