Skip to content

Relocate overflowing nav menus as overflow submenus - #42873

Merged
mdo merged 7 commits into
v6-devfrom
mdo/nav-overflow-menus
Sep 26, 2026
Merged

mdo merged 7 commits into
v6-devfrom
mdo/nav-overflow-menus

Conversation

@mdo

@mdo mdo commented Aug 28, 2026 •

Copy link
Copy Markdown
Member
  • Move an overflowing nav item's .menu into a .submenu of the overflow menu. Nested submenus stay reachable at narrow widths.
  • Move the original menu instead of cloning it, so ids, nested submenus, and live node state stay on one element.
  • Cache each hosted menu before it can move to a configured container, then restore it to its original position.
  • Reset open menu state and dispose stale Menu instances before relocation or overflow rebuilds.
  • Clone only the trigger. Strip menu data attributes, remove duplicate ids and links, and keep anchor triggers keyboard focusable.
  • Add menuStrategy and use fixed positioning in resizable examples so generated overflow menus are not clipped.
  • Hide the expanded nav until its first calculation completes, and center icon-only overflow toggles without an inline line box.
  • Use replaceChildren() when the overflow menu is cleared.
  • Add interaction and regression specs, plus a nested menu example in the docs.
  • Raise the JS budgets to 34.25KB for the standalone minified build, 58.25KB for the bundled minified build, and 73.25KB for the bundled unminified build.
  • Use a 3rem radius for pill navigation containers and links so they remain fully rounded.

Fixes #42845

@mdo
mdo requested a review from a team as a code owner August 28, 2026 19:09
@mdo mdo added this to v6.0.0 Aug 28, 2026
@github-project-automation github-project-automation Bot moved this to Inbox in v6.0.0 Aug 28, 2026
willbyers1

This comment was marked as spam.

mdo added 4 commits September 25, 2026 08:46
A nav item that hosts a menu used to collapse into a plain cloned link.
The menu became unreachable once the nav item overflowed, so a nested
menu was lost at narrow widths.

Move the original `.menu` into a `.submenu` of the overflow menu instead
of cloning it. One live menu keeps its ids, its nested submenus, and its
node state. Only the trigger is cloned, with the menu data attributes
stripped and `aria-haspopup` added. Restore moves the menu back to its
nav item and disposes the menu instances that were created.
`tsc` rejected `parent.append(menu)`, because `Node` does not declare
`append`. Store the parent as `ParentNode`, which does, and which is what
`Node.parentNode` already returns.
The submenu relocation adds about 0.4KB gzipped to the minified builds,
and both budgets had under 0.1KB of headroom. Move
`bootstrap.min.js` to 34.0KB and `bootstrap.bundle.min.js` to 56.0KB.
An open nav menu kept stale classes when its item moved into overflow.
Menus moved to another container were also missed, and cloned anchor
triggers lost keyboard focus.

Cache each hosted menu before it can move, reset open state during
relocation, and keep anchor triggers focusable. Add regression coverage
for relocation, nested interaction, container menus, and menu rebuilds.
Raise the bundled size budget to fit the added handling.
@mdo
mdo force-pushed the mdo/nav-overflow-menus branch from 8dfa0f9 to 0c76af4 Compare September 25, 2026 18:28
mdo added 2 commits September 25, 2026 11:50
The bundled build is 73.13KB after the nav overflow changes, which is
above the 73KB limit. Raise the limit to 73.25KB.
The radius token leaves visible corners on taller pill navigation. Use a
component-specific 3rem radius for the pill container and links.
@mdo
mdo requested a review from a team as a code owner September 25, 2026 19:15
Resizable examples clip the generated overflow menu because their fixed
positioning strategy cannot reach the toggle that NavOverflow creates.
Expose a menu strategy option and use it in those previews.

Hide the expanded nav until its first calculation completes to prevent a
startup flash and scrollbar. Remove the icon line box so icon-only toggles
stay vertically centered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Inbox

Development

Successfully merging this pull request may close these issues.

2 participants