Skip to content

fix(aria/menu): defer menu item focus in case menus in cdk overlay#33258

Open
ok7sai wants to merge 1 commit into
angular:mainfrom
ok7sai:fix/aria-menu-overlay
Open

fix(aria/menu): defer menu item focus in case menus in cdk overlay#33258
ok7sai wants to merge 1 commit into
angular:mainfrom
ok7sai:fix/aria-menu-overlay

Conversation

@ok7sai
Copy link
Copy Markdown
Member

@ok7sai ok7sai commented May 14, 2026

When menus are placed in a CdkConnectedOverlay, the menu trigger tries to focus the first menu item even before the menus are rendered and registered to the menu trigger.

When menus are placed in a `CdkConnectedOverlay`, the menu trigger tries
to focus the first menu item even before the menus are rendered and
registered to the menu trigger.
@ok7sai ok7sai force-pushed the fix/aria-menu-overlay branch from 6a24e03 to 7d0ba63 Compare May 14, 2026 23:41
@ok7sai ok7sai marked this pull request as ready for review May 14, 2026 23:54
@pullapprove pullapprove Bot requested review from andrewseguin and tjshiu May 14, 2026 23:55
Comment on lines +52 to +60
originalOnClick();
trigger.pendingFocusEffect();
};

const originalOnKeydown = trigger.onKeydown.bind(trigger);
trigger.onKeydown = (event: KeyboardEvent) => {
originalOnKeydown(event);
trigger.pendingFocusEffect();
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does await fixture.whenStable() in the test cases help instead of calling this method?

Copy link
Copy Markdown
Member Author

@ok7sai ok7sai May 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the UI patterns pendingFocusEffect() doesn't get called automatically because it's exposed for directives to actually use them as effect(() => pattern.pendingFocusEffect()). In the UI pattern tests the function has to be called manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants