Skip to content

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

Closed as not planned

Description

@jasmussen

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.

Activity

  1. jasmussen commented on Oct 21, 2025

    @jasmussen
    ContributorAuthor

    I'm going to close this one as unnecessary complexity that can be revisited at some point in the future in context perhaps of the interactivity API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions