fix: null guard in hideCtxMenu and scroll/touchmove listeners
hideCtxMenu now guards against null #ctx-menu element. scroll/touchmove listeners only fire when menu is actually visible, preventing spurious calls on every scroll event. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
96e3cb0451
commit
aa8d58d01f
1 file changed
+11
-3
@@ -153,13 +153,21 @@ export function showCtxMenu(e, song, list, idx) {
|
|||||||
}
|
}
|
||||||
export function hideCtxMenu() {
|
export function hideCtxMenu() {
|
||||||
const m = document.getElementById('ctx-menu');
|
const m = document.getElementById('ctx-menu');
|
||||||
|
if (!m) return;
|
||||||
m.style.display='none'; m.innerHTML='';
|
m.style.display='none'; m.innerHTML='';
|
||||||
}
|
}
|
||||||
document.addEventListener('click', e => {
|
document.addEventListener('click', e => {
|
||||||
if(!document.getElementById('ctx-menu').contains(e.target)) hideCtxMenu();
|
const m = document.getElementById('ctx-menu');
|
||||||
|
if (m && !m.contains(e.target)) hideCtxMenu();
|
||||||
});
|
});
|
||||||
document.addEventListener('scroll', () => hideCtxMenu(), { passive: true, capture: true });
|
document.addEventListener('scroll', () => {
|
||||||
document.addEventListener('touchmove', () => hideCtxMenu(), { passive: true, capture: true });
|
const m = document.getElementById('ctx-menu');
|
||||||
|
if (m && m.style.display !== 'none') hideCtxMenu();
|
||||||
|
}, { passive: true, capture: true });
|
||||||
|
document.addEventListener('touchmove', () => {
|
||||||
|
const m = document.getElementById('ctx-menu');
|
||||||
|
if (m && m.style.display !== 'none') hideCtxMenu();
|
||||||
|
}, { passive: true, capture: true });
|
||||||
document.addEventListener('keydown', e => { if(e.key==='Escape') hideCtxMenu(); });
|
document.addEventListener('keydown', e => { if(e.key==='Escape') hideCtxMenu(); });
|
||||||
|
|
||||||
// ─── PLAYLIST MODAL (Add to / Create) ───
|
// ─── PLAYLIST MODAL (Add to / Create) ───
|
||||||
|
|||||||
Reference in new issue
Block a user