Skip to content

Conversation

@amyleadem
Copy link
Contributor

@amyleadem amyleadem commented Jun 2, 2022

Description

Closes #4234

Preview links:

Problem

The .usa-megamenu.usa-nav__submenu::after and .usa-megamenu.usa-nav__submenu::before pseudo elements that surround the navigation on our megamenu extend beyond the viewport. This can cause problems when trying to capture screenshots, as well as other potential unknown issues.

Solution

Currently, these pseudo elements are set to a width of 100%, which is wider than they need to be and causes the elements to extend beyond the viewport.

Recalculating the width using relevant theme settings values allows the pseudo elements to line up with the edge of the viewport.

Testing

Because our header closes on click, I found the best method for testing this is to open desired story and not hit refresh to initialize the component.

  1. Open the header component megamenu and extended megamenu variants in Storybook
  2. Open web inspector and inspect .usa-megamenu.usa-nav__submenu::after and .usa-megamenu.usa-nav__submenu::before elements.
  3. Check if the elements extend beyond the viewport.

image

Additional information

Before you hit Submit, make sure you’ve done whichever of these applies to you:

  • Follow the 18F Front End Coding Style Guide and Accessibility Guide.
  • Run npm test and make sure the tests for the files you have changed have passed.
  • Run your code through HTML_CodeSniffer and make sure it’s error free.
  • Title your pull request using this format: [Website] - [UI component]: Brief statement describing what this pull request solves.

Comment on lines +13 to +16
$mw: smart-quote($header-max-width);
@if meta.type-of($header-max-width) == "string" {
$mw: units($header-max-width);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Checking for type in case user adds a unit value instead of a USWDS value. This maintains current capabilities.

@amyleadem amyleadem marked this pull request as ready for review June 2, 2022 22:01
@amyleadem amyleadem requested a review from mejiaj June 2, 2022 22:01
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.

Nice!

@thisisdano thisisdano merged commit 7dfaecf into develop Jun 3, 2022
@thisisdano thisisdano deleted the al-megamenu-viewport branch June 3, 2022 16:04
@thisisdano thisisdano mentioned this pull request Jun 17, 2022
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.

Megamenu dropdown extends to the right of the viewport.

3 participants