Skip to content

Fix submenu.hidden / CSS :hover+:focus-within conflict in menu #412

@coderabbitai

Description

@coderabbitai

Problem

In main/menu.js, the closeAllSubmenus() method closes submenus by setting submenu.hidden = true and item.setAttribute('aria-expanded', 'false'). However, style.css still has CSS rules that force submenus open via .menu-item:hover and .menu-item:focus-within. After focus returns to the parent item, the submenu can remain visible even though the JS state says it is closed.

Suggested Fix

One or more of the following approaches should be applied:

  1. Add a CSS rule to ensure [hidden] always wins:
    .submenu[hidden] {
      display: none !important;
    }
  2. In closeAllSubmenus() (and any other single-submenu close paths), call item.blur() or move focus to a neutral element (e.g. document.body) so :focus-within does not re-open the submenu.
  3. Clear currentOpenSubmenu in all relevant close paths.

Affected Files

  • main/menu.jscloseAllSubmenus() method (around lines 112–120)
  • style.css.menu-item:hover .submenu / .menu-item:focus-within .submenu rules

References

Raised by @lawsie.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions