Skip to content

Conversation

lpsinger
Copy link
Contributor

@lpsinger lpsinger commented Aug 1, 2023

Fixes #5417.

Summary

Provide a one or two sentence summary of the update that can be used in the changelog.

Breaking change

I'm not sure if this is considered a breaking change. Probably not.

Related issue

Closes #5417.

Preview link

Preview link:

Problem statement

USWDS 2 had some padding in nav submenus so that the submenu items were visually aligned with the nav menu button itself (see https://github.com/uswds/uswds/blob/v2.13.3/src/stylesheets/components/_navigation.scss#L374). This padding was removed in USWDS 3, and the nav submenus look off.

Solution

This PR adds a smidge of padding to restore the USWDS 2 appearance of nav submenus.

Testing and review

I tested this visually in my own site (https://gcn.nasa.gov).

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.

Hello @lpsinger,

Thank you for flagging this bug and your contribution to resolve!

Looking into the file changes, it appears the padding was removed in #4708. I believe it was removed because the hover state would not trigger when the padding is hovered.

We can get the best of both worlds by moving the padding to the left and right of the submenu item anchor tags! Using the u-padding-x()

.usa-nav__submenu-item {
    @include at-media($theme-header-min-width) {
      a {
+       @include u-padding-x(2);
- 	 padding: units(1);
	...
	}

This way, the navigation links will have the same layout as before, while being able to be hovered all the way to the edge of the dropdown. 👍

Screenshots

Develop

Screenshot 2023-09-26 at 5 17 52 PM

Before

Screenshot 2023-09-26 at 5 07 14 PM
Unable to hover anchor from padding

After
Screenshot 2023-09-26 at 5 06 48 PM
Able to hover anchor from padding

Let me know what you think!

Note
Vertical padding matches develop with this alternative. The proposed solution adds vertical padding to the menu.
If we want to increase vertical padding we can do so on the anchor element as well.

@lpsinger
Copy link
Contributor Author

@mahoneycm, with that approach, there isn't enough vertical padding on the top and bottom of the menu:

Screenshot 2023-09-26 at 17 56 44
Screenshot 2023-09-26 at 17 56 49

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.

It's looking great to me! Just one minor change to for code consistency 👍

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.

Looks great! Thanks for your responsiveness on this @lpsinger !

  • Resolves visual regression
  • Allows proper hover states
  • Passes linting and prettier checks

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.

Thanks for submitting this fix!

No issues with the default & extended, but question on megamenu variants. Tested small & large screen sizes.

Megamenu & Megamenu Extended padding

@thisisdano should the first column align with header logo on megamenu variants?

image


Header previews

Current (develop) Feature branch
Default Preview
Extended Preview
Megamenu Preview
Extended Megamenu Preview

@mejiaj mejiaj requested a review from thisisdano October 6, 2023 17:10
@amyleadem amyleadem added this to the uswds 3.7.1 milestone Nov 9, 2023
@mejiaj
Copy link
Contributor

mejiaj commented Nov 9, 2023

Follow-up to my previous comment on extended variants. We're going to review this PR as-is and follow-up with extended megamenu alignment in a follow-up PR.

@mejiaj mejiaj self-requested a review November 9, 2023 20:47
@mejiaj mejiaj changed the base branch from develop to header-nav-link-alignment November 21, 2023 21:45
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.

Thank you for submitting this! The alignment is looking better. Before final merge, I'd like to confirm how this interacts with #5630 but I think this is good to merge into the feature branch.

  • Confirm that the updated horizonal padding value matches the padding for .usa-nav__primary button in desktop view.

  • Confirm no visual regressions on the vertical padding in desktop view

    • Note: the vertical margin between links is the same as in develop, but there is additional vertical padding on the submenu element. I do not consider this to be a regression because it allows the vertical padding to match the increased horizontal padding.

    image

Note

I also investigated the alternative styling structure found in 2.13.0 that set alignment with the following rules:

.usa-nav__submenu {padding:1rem}
.usa-nav__submenu .usa-nav__submenu-item a {padding:0}
.usa-nav__submenu .usa-nav__submenu-item+* {margin-top: .75rem}

However, after looking at the changes in #4708, it makes sense that the changes in margin/padding were introduced to increase the target area for the links.

A couple of thoughts for future consideration:

  • Since there are visual changes for this addition, should it be considered enough of a breaking change to push it to a minor release? @mejiaj @mahoneycm
  • It might be beneficial for users if we created a theme setting for the horizontal padding on these elements, rather than hard-coding the values. Something to consider as a possible future enhancement.
  • Alternatively, we could also consider creating a horizontal padding variable inside `_usa-nav.scss" to ensure consistency across elements in the nav.

@mejiaj
Copy link
Contributor

mejiaj commented Nov 24, 2023

@amyleadem thanks for the review.

Relation to PR #5630

Thank you for submitting this! The alignment is looking better. Before final merge, I'd like to confirm how this interacts with #5630 but I think this is good to merge into the feature branch.

This only affects regular menu dropdowns on desktop, not megamenu variants.

Considerations

A couple of thoughts for future consideration:

  • Since there are visual changes for this addition, should it be considered enough of a breaking change to push it to a minor release? @mejiaj @mahoneycm

Not a breaking change for me.

  • With custom overrides. Users should check their dropdowns to ensure there aren't regressions with custom changes.
  • Visual display in-line to a previous version. Visual changes would have to be drastically different for this to be considered "breaking."
  • It might be beneficial for users if we created a theme setting for the horizontal padding on these elements, rather than hard-coding the values. Something to consider as a possible future enhancement.

Agreed. Can you link the enhancement to this issue for tracking?

  • Alternatively, we could also consider creating a horizontal padding variable inside `_usa-nav.scss" to ensure consistency across elements in the nav.

Do you see any conflicts with users wanting to override one, but not the other? It might also deviate from our approach of keeping components modular.

@amyleadem amyleadem merged commit 29dbbe5 into uswds:header-nav-link-alignment Nov 30, 2023
@lpsinger lpsinger deleted the nav-submenu-padding branch November 30, 2023 14:26
lpsinger added a commit to lpsinger/gcn.nasa.gov that referenced this pull request Dec 21, 2023
- Remove workaround for uswds/uswds#5418
- Add workaround for uswds/uswds#5558
- Fix footer snapped to bottom of page - not sure why I had to
  change this from `position: sticky` to `position: static` with
  the USWDS update, but I did
lpsinger added a commit to lpsinger/gcn.nasa.gov that referenced this pull request Dec 21, 2023
- Remove workaround for uswds/uswds#5418
- Add workaround for uswds/uswds#5558
- Fix footer snapped to bottom of page - not sure why I had to
  change this from `position: sticky` to `position: static` with
  the USWDS update, but I did
lpsinger added a commit to nasa-gcn/gcn.nasa.gov that referenced this pull request Dec 21, 2023
- Remove workaround for uswds/uswds#5418
- Add workaround for uswds/uswds#5558
- Fix footer snapped to bottom of page - not sure why I had to
  change this from `position: sticky` to `position: static` with
  the USWDS update, but I did
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.

USWDS - Bug: Nav submenu padding decreased unexpectedly in transition from USWDS 2 to 3, looks inconsistent with nav menu buttons
5 participants