Skip to content

Commit

Permalink
fix(menu): patch undefined lastFocusedItem
Browse files Browse the repository at this point in the history
  • Loading branch information
castastrophe authored and Westbrook committed Jan 25, 2023
1 parent 1666055 commit 772a7ea
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/menu/src/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ export class Menu extends SpectrumElement {
(!this.isLTR && code === 'ArrowRight');
if (shouldOpenSubmenu) {
const lastFocusedItem = this.childItems[this.focusedItemIndex];
if (lastFocusedItem.hasSubmenu) {
if (lastFocusedItem?.hasSubmenu) {
// Remove focus while opening overlay from keyboard or the visible focus
// will slip back to the first item in the menu.
this.blur();
Expand All @@ -485,7 +485,7 @@ export class Menu extends SpectrumElement {
}
if (code === 'Space') {
const lastFocusedItem = this.childItems[this.focusedItemIndex];
if (lastFocusedItem.hasSubmenu) {
if (lastFocusedItem?.hasSubmenu) {
// Remove focus while opening overlay from keyboard or the visible focus
// will slip back to the first item in the menu.
this.blur();
Expand Down

0 comments on commit 772a7ea

Please sign in to comment.