-
Notifications
You must be signed in to change notification settings - Fork 1.1k
USWDS - Nav: Fix padding in nav submenus #5418
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
USWDS - Nav: Fix padding in nav submenus #5418
Conversation
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.
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. 👍
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.
@mahoneycm, with that approach, there isn't enough vertical padding on the top and bottom of the menu: |
0e5b2f4
to
7de37a1
Compare
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.
It's looking great to me! Just one minor change to for code consistency 👍
7de37a1
to
873a870
Compare
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.
Looks great! Thanks for your responsiveness on this @lpsinger !
- Resolves visual regression
- Allows proper hover states
- Passes linting and prettier checks
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.
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?
Header previews
Current (develop ) |
Feature branch |
---|---|
Default | Preview |
Extended | Preview |
Megamenu | Preview |
Extended Megamenu | Preview |
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. |
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.
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.
- Note: the vertical margin between links is the same as in
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.
@amyleadem thanks for the review. Relation to PR #5630
This only affects regular menu dropdowns on desktop, not megamenu variants. Considerations
Not a breaking change for me.
Agreed. Can you link the enhancement to this issue for tracking?
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. |
- 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
- 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
- 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
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).