diff --git a/.ua/index.json b/.ua/index.json index 26c419d..15948a0 100644 --- a/.ua/index.json +++ b/.ua/index.json @@ -1,6 +1,6 @@ { "$schema": "ui-arch-registry-index/0.1", - "generatedAt": "2026-10-23T09:11:22.226Z", + "generatedAt": "2026-10-23T09:12:34.151Z", "repoRoot": ".", "packages": [ { diff --git a/packages/skin/ui/src/menu.ts b/packages/skin/ui/src/menu.ts index 4568873..0e7a650 100644 --- a/packages/skin/ui/src/menu.ts +++ b/packages/skin/ui/src/menu.ts @@ -1,7 +1,7 @@ import { effect, h, signal } from '@ui-arch/frame'; import type { MenuItem, MenuProps } from './types.js'; -/*** 下拉菜单:触发器 + 自绘弹层,项支持禁用 / 危险 / 分隔线;点项 / 点外部 / Esc 关闭,↑↓ 环形导航 ***/ +/*** 下拉菜单:触发器 + 自绘弹层,项支持禁用 / 危险 / 分隔线;点项 / 点外部 / Esc 关闭,↑↓ 环形导航 + Home/End 跳转 ***/ export function menu(props: MenuProps): HTMLElement { // —— 状态集中声明 —— const open = signal(false); // 弹层开合 @@ -61,6 +61,8 @@ export function menu(props: MenuProps): HTMLElement { trigger.focus(); // 收起后焦点回到触发器,键盘流不断 return; } + if (e.key === 'Home' && open()) { e.preventDefault(); focusables[0]?.focus(); return; } // Home 跳首项 + if (e.key === 'End' && open()) { e.preventDefault(); focusables[focusables.length - 1]?.focus(); return; } // End 跳末项 if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp') return; // 卫语句:只接管上下键 e.preventDefault(); if (!open()) {