Skip to content

Commit

Permalink
fix(menu): shift tab into anchor closes menu
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 589173373
  • Loading branch information
e111077 authored and Copybara-Service committed Dec 8, 2023
1 parent c9e8de0 commit c4cbd36
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions menu/internal/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,13 @@ export abstract class Menu extends LitElement {

if (event.relatedTarget) {
// Don't close the menu if we are switching focus between menu,
// md-menu-item, and md-list or if the anchor was click focused.
// md-menu-item, and md-list or if the anchor was click focused, but check
// if length of pointerPath is 0 because that means something was at least
// clicked (shift+tab case).
if (
isElementInSubtree(event.relatedTarget, this) ||
isElementInSubtree(event.relatedTarget, anchorEl)
(this.pointerPath.length !== 0 &&
isElementInSubtree(event.relatedTarget, anchorEl))
) {
return;
}
Expand Down

0 comments on commit c4cbd36

Please sign in to comment.