Skip to content

Open primary nav mega menu on click instead of hover#51

Merged
chellej merged 1 commit into
masterfrom
feat/click-to-open-nav-menu
Jul 16, 2026
Merged

Open primary nav mega menu on click instead of hover#51
chellej merged 1 commit into
masterfrom
feat/click-to-open-nav-menu

Conversation

@chellej

@chellej chellej commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The "What we do" mega menu opened/closed on mouseenter/mouseleave. Moving the pointer from the nav link down into the panel crosses a gap where neither element is hovered, firing mouseleave and closing the menu out from under the visitor mid-interaction.
  • The menu already had a working click-to-toggle handler alongside the hover handlers, plus outside-click and Escape to close. Removed the two hover listeners so click is the only way to open/close it.
  • No CSS changes needed - the mega panel is driven entirely by the .is-open class; there's no separate hover-based display rule to account for.

Test plan

  • deno check on site/js/main.js - syntax valid
  • Drove the built page via the Chrome DevTools Protocol (headless Chrome): a synthetic click opens the menu and sets aria-expanded=true; a synthetic mouseleave dispatched on both the trigger and the nav item no longer closes it (previously would have); a second click still toggles it closed
  • Screenshot-confirmed the menu renders open and stays open

The "What we do" mega menu opened and closed on mouseenter/mouseleave.
Moving the pointer from the nav link down into the panel crossed a
gap where neither element was hovered, firing mouseleave and closing
the menu out from under the visitor - reported as the menu
"disappearing under the mouse entirely too often."

The menu already had a working click-to-toggle handler alongside the
hover handlers (plus outside-click and Escape to close), so the fix
is to drop the two hover listeners and rely on click alone. No CSS
changes needed: the mega panel is driven entirely by the `.is-open`
class, with no hover-based display rule to fight.

Verified via Chrome DevTools Protocol against the built site: a
synthetic click opens the menu (aria-expanded=true), a synthetic
mouseleave on both the trigger and the item no longer closes it,
and a second click still toggles it closed.

Signed-off-by: chellej <197998703+chellej@users.noreply.github.com>
@chellej
chellej merged commit cbde086 into master Jul 16, 2026
3 checks passed
@chellej
chellej deleted the feat/click-to-open-nav-menu branch July 16, 2026 15:51
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.

2 participants