iter(g28): 浮层 Esc 逐层关闭,阻止冒泡连带关外层

This commit is contained in:
HIsheR
2026-10-26 11:38:44 +08:00
parent b263075e65
commit d9feeda0fd
10 changed files with 33 additions and 12 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ export function select(props: SelectProps): HTMLElement {
};
root.addEventListener('keydown', (e: KeyboardEvent) => {
if (e.key === 'Escape') { open(false); trigger.focus(); return; } // Esc 关闭并回焦触发器
if (e.key === 'Escape') { e.stopPropagation(); open(false); trigger.focus(); return; } // Esc 只关本层并回焦触发器
if (e.key === 'ArrowDown' || e.key === 'ArrowUp') {
e.preventDefault(); // 阻止页面滚动
if (!open()) { open(true); options[0]?.focus(); return; } // 未展开:展开并聚焦首个选项