Skip to content

docs: disable overlay close-on-escape in Aria menubar examples#69123

Open
Daherkarim wants to merge 1 commit into
angular:mainfrom
Daherkarim:kdaher/menubar-escape-hover-stuck
Open

docs: disable overlay close-on-escape in Aria menubar examples#69123
Daherkarim wants to merge 1 commit into
angular:mainfrom
Daherkarim:kdaher/menubar-escape-hover-stuck

Conversation

@Daherkarim
Copy link
Copy Markdown

What / Why

In the Aria menubar examples on angular.dev, the menus become permanently
unusable after this interaction:

  1. Open a top-level menu (e.g. File) and move focus onto one of its items.
  2. Hold the Escape key.
  3. Mouse over the menubar.

Afterwards, several menus (e.g. Insert, Format) no longer open — neither
on hover nor on click.

Root cause

Each menu is rendered in a cdkConnectedOverlay, which detaches the top-most
overlay on every Escape press (disableClose defaults to false).
The top-level menus are always attached, so a detached overlay never reattaches
and its viewChild reference becomes undefined. Holding Escape detaches the
overlays one by one, permanently breaking menus like Insert and Format.

This isn't a CDK bug — close-on-Escape is intentional cdkConnectedOverlay
behavior. The menu pattern should own open/close state, which is what the
combobox and toolbar examples already do via cdkConnectedOverlayDisableClose.

Fix

Add [cdkConnectedOverlayDisableClose]="true" to the overlay templates across
the basic, disabled, and rtl menubar examples (and their material/retro
variants) — 9 files in total.

Notes

The same fix is being applied to the matching examples in angular/components
(the two example sets are maintained separately). Only example templates change.

The Aria menubar examples render each menu in a `cdkConnectedOverlay`,
which detaches the top-most overlay on every Escape keypress
(`disableClose` defaults to `false`). The top-level menus are always
attached, so a detached overlay never reattaches and its `viewChild`
reference becomes `undefined`. Holding Escape detaches the overlays one by
one, permanently breaking menus such as "Insert" and "Format".

Set `cdkConnectedOverlayDisableClose` on the example overlays so the menu
pattern remains the single owner of open/close state, matching the
combobox and toolbar examples. Applied to the basic, disabled, and rtl
menubar examples (and their material/retro variants).
@pullapprove pullapprove Bot requested a review from kirjs June 3, 2026 15:06
@angular-robot angular-robot Bot added the area: docs Related to the documentation label Jun 3, 2026
@ngbot ngbot Bot added this to the Backlog milestone Jun 3, 2026
@JeanMeche JeanMeche requested a review from wagnermaciel June 3, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: docs Related to the documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant