iter(g28): 浮层 Esc 逐层关闭,阻止冒泡连带关外层
This commit is contained in:
@@ -35,7 +35,7 @@ function openViewer(src: string, alt?: string): void {
|
||||
document.removeEventListener('keydown', onKey);
|
||||
prev?.focus?.();
|
||||
};
|
||||
const onKey = (e: KeyboardEvent) => e.key === 'Escape' && close();
|
||||
const onKey = (e: KeyboardEvent) => { if (e.key !== 'Escape') return; e.stopPropagation(); close(); }; // 预览层 Esc 自关,不连带关外层
|
||||
mask.addEventListener('click', close);
|
||||
document.addEventListener('keydown', onKey);
|
||||
document.body.appendChild(mask);
|
||||
|
||||
Reference in New Issue
Block a user