fix(ctxmenu): Esc with the context menu open closes only the menu
Same Esc fall-through class: the menu's Esc handler was bubble-phase and didn't stop the keystroke, so the slideover capture handler fired first and popped the discard prompt while the menu also hid. Capture + stopPropagation, gated on the menu being visible; registered before the slideover handler (installCustomContextMenu runs at the top of init) so ordering is guaranteed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6979,9 +6979,15 @@ function installCustomContextMenu() {
|
||||
document.addEventListener('mousedown', ev => {
|
||||
if (!ev.target.closest('.custom-ctxmenu')) hide();
|
||||
});
|
||||
// Capture + stopPropagation: Esc with the menu open must close ONLY the
|
||||
// menu — otherwise the same keystroke reaches the slideover/fallback
|
||||
// handlers and also closes (or discard-prompts) whatever is behind.
|
||||
document.addEventListener('keydown', ev => {
|
||||
if (ev.key === 'Escape') hide();
|
||||
});
|
||||
if (ev.key !== 'Escape') return;
|
||||
if (menu.classList.contains('is-hidden')) return;
|
||||
ev.stopPropagation();
|
||||
hide();
|
||||
}, true);
|
||||
window.addEventListener('blur', hide);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user