Repository navigation
mega-menu: a wide panel taller than the room below it scrolls inside itself - #26
Merged
Merged
Conversation
…itself Hosts put the menu in a sticky header, where the page cannot scroll a tall panel into view, so its last links were out of reach (superherotech.ai's Features panel is ~1,019px at 1440 wide). The open panel is now capped at var(--mm-panel-max, calc(100dvh - var(--mm-panel-top, 5rem))), border-box, with overflow-y: auto and overscroll-behavior: contain. The script measures where the panel starts from layout offsets (the opening animation translates it) on open, and again on scroll and resize while open. The collapsed accordion lifts the cap; its list already scrolls as a whole. --mm-panel-max is documented in the header and the catalogue. check-mega-menu.mjs runs the shipped panelTop against fake panels, pins the stylesheet (source and built), the script's re-measuring and the docs, and kills 21 mutants. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In wide (non-compact) mode
.mm__panelhad no max-height and no overflow. Hosts usually put the menu in a sticky header, where the page cannot scroll a tall panel into view, so its bottom links are unreachable. On superherotech.ai the Features panel is about 1,019px tall at 1440px wide (after ecropolis/SuperheroTech#37). On an 800–900px-tall window, Controls & details and "See all elements" are cut off.Fix
.mm__panelgetsmax-height: var(--mm-panel-max, calc(100dvh - var(--mm-panel-top, 5rem))), plusbox-sizing: border-box,overflow-y: autoandoverscroll-behavior: contain. Border-box keeps the 1px top rule inside the cap, so the bottom edge stays on screen.--mm-panel-topon the open panel to where the panel starts.offsetParentrect +clientTop+offsetTop, oroffsetTop - scrollYagainst<body>), not the panel's own box, because the opening animation translates the panel.open(), so there is no uncapped first frame. It measures again at most once a frame on scroll and resize while a panel is open, which covers a header that shrinks on scroll.:hover/:focus-withinreveal is unchanged, and the cap assumes the panel starts 5rem down.max-height: none; overflow: visible), since its list already scrolls as a whole.--mm-panel-maxreplaces the cap: a length such as70vh, ornoneto lift it. It is documented in the component header, the catalogue's theming list, and a new a11y line.Check
New
scripts/check-mega-menu.mjs, added tonpm run check:// <mm-fit>block in the built page must equal the source's, and runs against 5 fake-panel cases. Reading the panel's own box throws.open()callsfit(), a passive scroll listener and a resize listener re-measure, and nothing is measured while collapsed.--mm-*the stylesheet reads, except the script-set--mm-panel-top, must be in both the header and the catalogue, and vice versa.Full
npm run checkis green locally.Verified in the gallery
I ran a temporary gallery page (not committed) in headless Chrome over CDP. It had a sticky header,
--mm-anchor: static, and a Features panel of seven categories plus "More → See all elements" (scrollHeight 1,272px). The page was scrolled 600px:--mm-panel-top: 84pxscrollYstays 600 even past the end--mm-panel-topfollows to 63px, bottom still 820max-height: none; overflow: visible; the list (80vh) scrollsWithout JavaScript, the 5rem stand-in is 4px short for this 84px header, so the panel's bottom 4px of padding sit below the fold. The links are still all reachable. A host with a much taller header can set
--mm-panel-maxfor the no-JS case.🤖 Generated with Claude Code