Skip to content

Relocate overflowing nav menus as overflow submenus - #42873

Open
mdo wants to merge 3 commits into
v6-devfrom
mdo/nav-overflow-menus
Open

Relocate overflowing nav menus as overflow submenus#42873
mdo wants to merge 3 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 instead of dropping it. Nested submenus stay reachable at narrow widths.
  • Move the original menu rather than clone it, so ids, nested submenus, and live node state stay on one element.
  • Clone only the trigger: strip data-bs-* (except data-bs-theme), drop href and id, add aria-haspopup and aria-expanded, and set role="button" on an anchor.
  • Restore returns each relocated menu to its original position and disposes the Menu instances that NavOverflow created.
  • Swap innerHTML = '' for replaceChildren() when clearing the overflow menu.
  • Add specs for the relocate and restore paths, plus a nested menu example in the docs.
  • Raise the bootstrap.min.js budget to 34.0KB and the bootstrap.bundle.min.js budget to 56.0KB. This adds about 0.4KB gzipped and both budgets had under 0.1KB of headroom.

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.
@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
mdo added 2 commits August 28, 2026 12:17
`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.
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.

1 participant