Skip to content

Commit 6edeaca

Browse files
committed
fix: if a submenu has already been removed from the DOM tree, don't try to hide it again
1 parent 104754e commit 6edeaca

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/ui/menu/menu-list.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,14 @@ export class _MenuListState implements MenuListState {
434434
// Notify our parent
435435
if (this.parentMenu) this.parentMenu.openSubmenu = null;
436436

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

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

444447
// Change the focus to avoid a spurious blur event

0 commit comments

Comments
 (0)