Skip to content

feat(a11y): improve core interaction accessibility and add audit guide#20

Open
leno23 wants to merge 19 commits into
mainfrom
codex/improve-accessibility-for-key-components
Open

feat(a11y): improve core interaction accessibility and add audit guide#20
leno23 wants to merge 19 commits into
mainfrom
codex/improve-accessibility-for-key-components

Conversation

@leno23
Copy link
Copy Markdown
Owner

@leno23 leno23 commented May 16, 2026

Motivation

  • 提升关键交互组件(Modal / Dropdown / Menu / Select / 表单接入层)的键盘可用性、焦点管理与语义/ARIA 一致性,并把审计结果与使用注意写入文档以便可追踪审计。

Description

  • Modal: 在打开时记录并恢复先前焦点,打开时将焦点移动到关闭按钮,并通过 aria-labelledby 将标题与 role="dialog" 关联。
  • Dropdown: 为触发器添加 aria-expanded/aria-haspopup/aria-controls,支持 Enter/Space/ArrowDown 打开、ArrowUp/ArrowDown 导航与 Escape 关闭并回焦,同时添加 click-outside 行为和活动项 tabIndex 管理。
  • Menu: 在容器层监听方向键(垂直上下、水平左右)实现箭头遍历,并使用 roving tabIndex(活动项 0 其余 -1)和内部活动 key 状态。
  • FormItem: 为每个字段生成 id 并使 label 使用 htmlFor 绑定控件,出错时向控件注入 aria-invalidaria-describedby 并为错误文案输出 id。
  • Docs: 新增 docs/guide/accessibility.md 包含 a11y 检查清单、组件级审计结果、每个修复点的“问题-改法-验证方式”,并在侧边栏添加“可访问性”入口。
  • 兼容性说明: 变更为向后兼容的行为增强(未修改公开 API),并在文档中列出可能影响自定义 onKeyDown 冒泡逻辑或依赖“打开不夺焦”的场景。

Testing

  • 运行 npm run typecheck:ui; 在最初修改后出现 TypeScript 类型错误并已修复,最终 tsc --noEmit 通过。
  • 运行 npm run lint:ui(内部会触发 typecheck 步骤)且 ESLint 检查通过。

Codex Task

cursoragent and others added 19 commits April 11, 2026 16:13
Co-authored-by: 吴杨帆 <leno23@users.noreply.github.com>
Co-authored-by: 吴杨帆 <leno23@users.noreply.github.com>
Co-authored-by: 吴杨帆 <leno23@users.noreply.github.com>
…ace, Divider, SplitPane)

Co-authored-by: 吴杨帆 <leno23@users.noreply.github.com>
Add VitePress markdown docs with LivePlayground examples and API tables for:
Input, InputNumber, AutoComplete, Select, Checkbox, Radio, Switch,
DatePicker, TimePicker, Slider, Rate, Upload, Form, Calendar,
Transfer, Cascader, TreeSelect, ColorPicker, Segmented, Mentions

Co-authored-by: 吴杨帆 <leno23@users.noreply.github.com>
…avigation)

Co-authored-by: 吴杨帆 <leno23@users.noreply.github.com>
…two-level menu

New components (matching Ant Design API patterns):
- Layout: Flex
- Form: AutoComplete, InputNumber, TimePicker
- Feedback: Alert, Skeleton, Popconfirm, Spin
- Data: List, Carousel, Image
- Navigation: FloatButton

Sidebar changes:
- Restructured from flat category links to two-level collapsible menu
- Each component now has its own dedicated page with demo and API docs
- Removed old single-page-per-category docs
- Updated overview page with complete component listing

Co-authored-by: 吴杨帆 <leno23@users.noreply.github.com>
Add AGENTS.md with Cursor Cloud development instructions
…tion-display

docs: improve component overview with category cards and styles
…-to-table-component

feat(table): add pagination configuration and simple built-in pager
feat(form): support event and value-first onChange values
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eaa97af5e7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +75 to +79
const handleTriggerKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {
if (event.key === 'ArrowDown' || event.key === 'Enter' || event.key === ' ') {
event.preventDefault()
setOpen(true)
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Move focus into dropdown menu on keyboard open

When the trigger is opened via Enter/Space/ArrowDown, the handler only calls setOpen(true) and leaves DOM focus on the trigger button. Because arrow-key navigation is wired on the <ul> (onKeyDown={handleMenuKeyDown}), subsequent arrow presses do not reach the menu unless the user tabs manually first, so the advertised keyboard flow (open then navigate with arrows) does not work for keyboard-only users.

Useful? React with 👍 / 👎.

Comment on lines +183 to +184
const fieldId = `field-${name}`
const errorId = `${fieldId}-error`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Generate per-instance ids instead of name-based ids

Deriving fieldId purely from name makes IDs collide whenever multiple forms or repeated sections reuse the same field name (for example two email items on one page). That creates duplicate id/htmlFor/aria-describedby targets, which can cause labels and error text to resolve to the wrong control and breaks valid accessibility wiring introduced by this change.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants