Skip to content

Commit c4cbd36

Browse files
Elliott Marquezcopybara-github
authored andcommitted
fix(menu): shift tab into anchor closes menu
PiperOrigin-RevId: 589173373
1 parent c9e8de0 commit c4cbd36

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

menu/internal/menu.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,13 @@ export abstract class Menu extends LitElement {
518518

519519
if (event.relatedTarget) {
520520
// Don't close the menu if we are switching focus between menu,
521-
// md-menu-item, and md-list or if the anchor was click focused.
521+
// md-menu-item, and md-list or if the anchor was click focused, but check
522+
// if length of pointerPath is 0 because that means something was at least
523+
// clicked (shift+tab case).
522524
if (
523525
isElementInSubtree(event.relatedTarget, this) ||
524-
isElementInSubtree(event.relatedTarget, anchorEl)
526+
(this.pointerPath.length !== 0 &&
527+
isElementInSubtree(event.relatedTarget, anchorEl))
525528
) {
526529
return;
527530
}

0 commit comments

Comments
 (0)