cleaned up album selection behavior, context menu now closes when clicking outside of it

This commit is contained in:
2026-02-21 11:02:54 -05:00
parent 402789e763
commit 4d9ab5d2b8
5 changed files with 183 additions and 148 deletions
@@ -182,6 +182,23 @@ export class PlaylistView
this.closePlaylistContextMenu();
};
private mousedownCloseHandler = (
e: MouseEvent,
) => {
const path = e.composedPath();
const popup = this.contextMenuPopup;
const submenu = this.playlistSubmenuPopup;
const plPopup =
this.playlistContextMenuPopup;
if (popup && path.includes(popup)) return;
if (submenu && path.includes(submenu)) return;
if (plPopup && path.includes(plPopup)) return;
this.closeContextMenu();
this.closePlaylistContextMenu();
};
private clearSelectionHandler = (e: MouseEvent) => {
const path = e.composedPath();
const isTrackClick = path.some(
@@ -664,6 +681,10 @@ export class PlaylistView
'contextmenu',
this.closeContextMenuHandler,
);
document.addEventListener(
'mousedown',
this.mousedownCloseHandler,
);
document.addEventListener(
'click',
this.clearSelectionHandler,
@@ -687,6 +708,10 @@ export class PlaylistView
'contextmenu',
this.closeContextMenuHandler,
);
document.removeEventListener(
'mousedown',
this.mousedownCloseHandler,
);
document.removeEventListener(
'click',
this.clearSelectionHandler,