Skip to content

feat(cdk-experimental/menu): enable keyboard handling for context menu #20171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

andy9775
Copy link
Contributor

@andy9775 andy9775 commented Aug 3, 2020

By default on both Mac and Windows the context menu keyboard trigger is emitted as a contextmenu
mouse event automatically, eliminating the need to handle keyboard events specifically for context
menus. Therefore, this simply places focus on the first menu item in the opened context menu
relying on the existing menu and menu item keyboard handling logic.

@andy9775 andy9775 requested a review from jelbourn as a code owner August 3, 2020 20:28
@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Aug 3, 2020
@andy9775 andy9775 requested a review from teflonwaffles August 3, 2020 20:29
@@ -216,6 +216,7 @@ export class CdkContextMenuTrigger implements OnDestroy {

this._contextMenuTracker.update(this);
this.open({x: event.clientX, y: event.clientY});
this._menuPanel._menu?.focusFirstItem('mouse');
Copy link
Member

@jelbourn jelbourn Aug 3, 2020

Choose a reason for hiding this comment

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

I don't know that this should be mouse, since one could trigger this event with the keyboard.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Referring to the fact that this method handles the keyboard shortcut to trigger a context menu??

Copy link
Member

Choose a reason for hiding this comment

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

Yes, exactly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. As discussed, fixed to consider to clicked mouse button when setting focus

@andy9775 andy9775 force-pushed the cdk-menu-context-menu-keyhandling branch from 93f226b to a16f8f3 Compare August 4, 2020 16:29
By default on both Mac and Windows the context menu keyboard trigger is emitted as a contextmenu
mouse event automatically, eliminating the need to handle keyboard events specifically for context
menus. Therefore, this simply places focus on the first menu item in the opened context menu
relying on the existing menu and menu item keyboard handling logic.
@andy9775 andy9775 force-pushed the cdk-menu-context-menu-keyhandling branch from a16f8f3 to 9c18aec Compare August 4, 2020 16:29
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM

@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker merge safe target: minor This PR is targeted for the next minor release labels Aug 4, 2020
@mmalerba mmalerba merged commit 0b5eaa8 into angular:master Aug 5, 2020
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants