-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
fix(menu): set appropriate origin when restoring focus #9303
fix(menu): set appropriate origin when restoring focus #9303
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
30cced2
to
b9b329d
Compare
Included the |
src/lib/menu/menu-trigger.ts
Outdated
@@ -208,8 +211,12 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy { | |||
} | |||
|
|||
/** Focuses the menu trigger. */ | |||
focus() { | |||
this._element.nativeElement.focus(); | |||
focus(origin: FocusOrigin = 'program') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a @param
JsDoc
src/lib/menu/menu-trigger.ts
Outdated
@@ -274,8 +281,10 @@ export class MatMenuTrigger implements AfterContentInit, OnDestroy { | |||
// We should reset focus if the user is navigating using a keyboard or | |||
// if we have a top-level trigger which might cause focus to be lost | |||
// when clicking on the backdrop. | |||
if (!this._openedByMouse || !this.triggersSubmenu()) { | |||
if (!this._openedByMouse) { | |||
this.focus(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment that focus style will show for both program
and keyboard
, so we don't have to specify which?
Sets the correct focus origin depending on the way a menu has been opened. Fixes angular#9292.
b9b329d
to
612d98b
Compare
Sets the correct focus origin depending on the way a menu has been opened. Fixes angular#9292.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sets the correct focus origin depending on the way a menu has been opened.
Fixes #9292.