Skip to content

Commit

Permalink
fix: if a submenu has already been removed from the DOM tree, don't t…
Browse files Browse the repository at this point in the history
…ry to hide it again
  • Loading branch information
arnog committed Dec 23, 2024
1 parent 104754e commit 6edeaca
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/ui/menu/menu-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,14 @@ export class _MenuListState implements MenuListState {
// Notify our parent
if (this.parentMenu) this.parentMenu.openSubmenu = null;

if (supportPopover() && this._element?.popover) this.element.hidePopover();
// If we're no longer in the DOM tree, we can bail
if (!this._element?.isConnected || !this._element.parentElement) return;

if (supportPopover() && this._element?.popover) this._element.hidePopover();

// We're going to do some focus manipulation, but we don't want parents
// to react to these events (they may think the host has lost focus and
// react innapropriately).
// react inappropriately).
suppressFocusEvents();

// Change the focus to avoid a spurious blur event
Expand Down

0 comments on commit 6edeaca

Please sign in to comment.