Skip to content
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

Navigation submenus: Add viewport awareness smarts to the opening direction #36241

Open
jasmussen opened this issue Nov 5, 2021 · 0 comments
Labels
[Block] Navigation Affects the Navigation Block [Type] Enhancement A suggestion for improvement.

Comments

@jasmussen
Copy link
Contributor

When a navigation block has submenus, these submenus open by default, down and right:

Screenshot 2021-11-05 at 08 46 39

Screenshot 2021-11-05 at 08 47 09

There is CSS in place to open down and left when the navigation menu is justified right:
Screenshot 2021-11-05 at 08 49 06

Screenshot 2021-11-05 at 08 49 09

This works reasonably well for basic menus, and benefits from being CSS only. However a few limitations are also present. For one, if your menu is left aligned, but has enough items for there to be a dropdown menu towards the right of the screen, this will still open rightwards:
dropdowns

There's also the challenge of nested submenus continuing in their initial direction, which means when you get enough levels deep, you'll bump off the edge of the screen.

In both cases, you can editorially take care to avoid this. But it would be nice to explore some programmatic enhancements to flip the direciton of submenus based on available viewport space.

This could be extended to nested submenus as well, going back and forth based on available space, and even flipping the direction of the chevron to point in the direction the menu opens it.

It would need to be resize aware, and would probably work best by applying CSS classes to submenu containers, such as opens-left or opens-right, or any better terms we can think of.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Navigation Affects the Navigation Block [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

1 participant