Repository navigation
Conversation
Collaborator
Author
Review 修复(第二轮独立 review 后)两轮独立 review 发现的 P1 全部修复并推送: 1. 多弹窗 Esc 全关 + 测试假绿灯
2. 关闭按钮键盘不可达
3. focus trap 无层栈仲裁
4. Select IME 组合态守卫(CJK 高频路径)
全量 2539/2539 通过(此前一轮曾出现 2 个负载 flake,单跑均绿,与本 PR 改动无关) 遗留 P2(建议后续 issue 跟进)
|
Collaborator
Author
Review 结论与修复(已提交
|
| # | 问题 | 修复 |
|---|---|---|
| 1 | useId 是 Vue 3.5 才有的 API,而 peerDependencies 为 vue ^3.2.24;静态具名导入 import { useId } from 'vue' 在低版本原生 ESM 下会直接抛错(构建产物 external 化后更危险) |
新增 components/_util/use/useId.ts:计数挂在 appContext 上(每应用一份,SSR 服务端/客户端生成顺序一致,不会 hydration 不匹配),4 处引用改为本地实现,不依赖 Vue 版本 |
P1
| # | 问题 | 修复 |
|---|---|---|
| 2 | FFormItem 无 label 时仍注入 labelId,控件 aria-labelledby 指向不存在的元素(实测值为 v-0,页面无该元素) |
改为 computed,无 label 且无 #label 插槽时注入 undefined;FormItemInject.labelId 类型同步改为 Ref<string | undefined> |
| 3 | aria-labelledby 指向整个 header,关闭按钮的 aria-label 被算进可访问名,读屏播报成「删除确认 关闭」 |
只指向标题元素。Modal 复用已有的标题 div;Drawer 新增一层仅含标题的 div(关闭按钮是 position: absolute,不影响布局) |
| 4 | 焦点进入 Teleport 到 body 的浮层后,按 Tab 被弹层焦点圈闭抢回弹层(Modal 内的 Select / DatePicker 面板) | Popper wrapper 增加 data-fes-focus-scope 标记,焦点圈闭检测到焦点在该标记内且不在弹层子树时放行 |
| 5 | filterable 时 role="combobox" / aria-expanded / aria-activedescendant 挂在外层 div,但焦点实际在内部 input 上,这些属性不生效(aria-activedescendant 只对当前聚焦元素有效) |
aria 值改为 props 传入 SelectTrigger,filterable(含 remote)时语义与关联挂到内部 input,外层不再声明 combobox;同时 filterable 且输入框已有文本时不再劫持 Home/End |
P2
| # | 问题 | 修复 |
|---|---|---|
| 6 | useEsc 层栈按 escClosable 增删,下层弹层重新打开 escClosable 时会被 push 到栈顶,抢走本该属于上层的 Esc |
层栈只按 open 维护,escClosable 在消费时实时读取;栈顶不可关闭时吞掉 Esc,不下沉误关下层。顺带去掉 window 上的 no-op stopPropagation |
| 7 | useFocusTrap.setup() 在 await nextTick() 后未复查 open,等待期间关闭会残留 trap 霸占栈顶 |
增加 open 复查;可聚焦元素过滤补充排除 hidden / aria-hidden="true" / visibility: hidden |
| 8 | a11y.spec.ts 断言空转:jsdom 下 offsetWidth/offsetHeight 恒为 0,焦点圈闭实际走的是「无可聚焦元素」兜底分支,Tab 断言没有覆盖真实逻辑;另外 FModal/FDrawer 传了未声明的 appendToContainer |
对尺寸打桩以覆盖真实分支;去掉无效传参;新增 Drawer 焦点圈闭、无 label 的 FormItem、可访问名只含标题、escClosable 顺序、浮层放行、filterable aria、只配 name 的 tab、IME 守卫、错误播报等用例(14 → 28 个) |
| 9 | popper role 类型收窄为 4 个字面量,业务无法使用 listbox/alertdialog 等 |
放宽为 String;并补齐文档(Popper role + Select/Tabs/Modal/Drawer/Switch 无障碍说明) |
你 P2 清单里的 4 项也一并修了
forbidChildValidate重提供上下文时丢labelId→ 补透传(当前无消费方,属一致性修复)- Tabs 只配
name的页签不可键盘到达 →value缺省回退name,贯穿tab.tsx/tabs.tsx/mapTabPane(顺带修掉「全部 pane 同时渲染」) - Select 分组标题在
listbox内是非法子节点 →role="presentation" - 键盘导航不滚动虚拟列表 → 高亮项变化时
scrollToIndex(虚拟)/scrollIntoView(普通)
明确未做(建议单独 issue)
aria-modal="true"未配套把背景置为inert:需要遍历并标记 body 其他子树,影响面较大。- 校验错误信息仍未与控件
aria-describedby关联(error div 没有 id),仅做到role="alert"播报;同时去掉了与role="alert"冲突的aria-live="polite"。 - 多应用同页的 id 冲突注意事项与 Vue 官方
useId一致(各应用计数独立)。
感谢补充的 IME 组合态守卫,这部分逻辑复核无误。
对比 naive-ui / element-plus / ant-design-vue 的 a11y 专项研究显示, 全库 67 个组件仅 collapse 有 aria 语义,本次补齐核心交互链路: 一、FPopper role 参数化(修复错误标注) - popper.tsx 原给所有弹层 wrapper 硬编码 role="tooltip", Select/Cascader/DatePicker 下拉被读屏器当作提示气泡直接跳过 - 新增 role prop(tooltip/dialog/menu/none),默认不输出; FTooltip 显式声明 role="tooltip" 二、FModal/FDrawer 对话框语义 + 焦点管理(参考 element-plus el-focus-trap / antd vc-dialog) - role="dialog" + aria-modal + aria-labelledby(标题 useId 关联) - 新增 useFocusTrap:打开时初始聚焦(data-autofocus 优先)、 Tab 圈闭(Shift+Tab 循环)、关闭后焦点归还;SSR 安全 - 关闭按钮补 role="button" + aria-label(新增三语言包 modal.close / drawer.close) 三、修 useEsc 多弹窗 bug - modal/drawer 原调用未传 open:window keydown 常驻 + 多弹窗全部响应同一 Esc - 重构为 [open, escClosable] 联合 watch,仅打开期间监听 四、FSelect 键盘化 + combobox 语义(参考 antd vc-select) - 触发器 role="combobox" + aria-expanded/haspopup/controls/ activedescendant(useId 生成,焦点保留在触发器上) - 下拉容器 role="listbox",选项 role="option" + aria-selected/aria-disabled + id - 键盘导航:ArrowDown/ArrowUp 循环移动高亮、Enter 打开/选中、 Esc 收起、Home/End 跳首尾;按键归一化兼容合成事件 五、FSwitch / FTabs / FForm 语义 - Switch:role="switch" + aria-checked + tabindex + Space/Enter 键盘触发 - Tabs:tablist/tab 语义 + roving tabindex + 方向键切换 (水平左右/垂直上下) - FormItem:label useId + 注入 labelId,FInput/FSelect 触发器 aria-labelledby 关联;错误提示 role="alert" aria-live 测试:新增 a11y 专项 spec 12 用例(语义断言 + 键盘链路 + 焦点圈闭 + 多弹窗 Esc),全量 2537/2537 绿 Signed-off-by: harrywan <harrywan@webank.com>
独立 review 发现的三个 P1 问题修复: 一、多弹窗 Esc 全关(P1) - useEsc 每个 instance 独立注册 window keydown 且无仲裁, 双 Modal 同开 / Modal+Drawer 叠放时一次 Esc 关闭全部弹层 - 修复:模块级 escStack 层栈,仅栈顶(最后打开)的弹层消费 Esc 并 stopPropagation,下层弹层保持 - 附带修复卸载清理:onBeforeUnmount 原走 syncListener 在 open/escClosable 为 true 时反而会注册监听,改为无条件出栈移除 二、关闭按钮键盘不可达(P1) - close 图标原为 div role="button":role 不产生可聚焦性, Tab 圈闭跳过关闭按钮,键盘用户无法关闭弹层 - 修复:改用原生 <button type="button">(天然 Enter/Space 触发 + Tab 可达),modal/drawer 的 close 样式补 button reset 三、focus trap 无层栈仲裁(P1) - Modal 上叠 Drawer 时两个 trap 都在 window 捕获阶段监听 Tab, 各自拉焦存在抖动竞态 - 修复:trapStack 层栈,仅栈顶 trap 响应 Tab; 初始聚焦仅在焦点不在容器内时执行(避免命令式弹窗连续开关时 抢焦引发的时序敏感);焦点归还仅在当前焦点位于已关闭弹层内 或 body 时执行 四、测试重写 - 原多弹窗 Esc 用例是假绿灯(emitted 挂在模板根 div 上收不到 子组件事件,断言永真)——重写为 findAllComponents 逐组件断言 - 新增「Esc 关栈顶后再 Esc 关下层」用例覆盖层栈弹出语义 全量 2538 用例:2536 绿 + 2 个负载 flake(modal-api-branches 节流轮询与 docs-demo changeLocale 大 demo 超时,单跑均绿) Signed-off-by: harrywan <harrywan@webank.com>
独立 review 探针证实的 P1:filterable Select 打开下拉、 IME 组合中按 Enter 确认候选词(真实浏览器 keydown isComposing=true / keyCode 229),会被当成选项选中直接 触发 update:modelValue——中文输入场景高频误操作。 修复:onTriggerKeyDown 入口增加组合态守卫 (e.isComposing || e.keyCode === 229 时直接 return), 组合结束后的 Enter 行为不变。 测试:新增 a11y 用例覆盖三种序列——组合中 Enter 不选中 且下拉保持、keyCode 229 变体同样守卫、组合结束后 Enter 正常选中。全量 2539/2539 通过。 Signed-off-by: harrywan <harrywan@webank.com>
- useId: 自实现 SSR 稳定的 id 生成(计数挂在 appContext), 不再依赖 Vue 3.5 的 useId(peerDependencies 为 ^3.2.24) - FFormItem: 无 label 时不再注入 labelId,避免 aria-labelledby 指向不存在的元素;错误信息去掉与 role=alert 冲突的 aria-live=polite - FModal/FDrawer: aria-labelledby 只指向标题元素,可访问名不再 包含关闭按钮的「关闭」;容器 ref 复用 modalRef/drawerRef - useFocusTrap: 焦点位于 Teleport 浮层内时放行不抢焦; setup 等待期间弹层已关闭则不再注册;排除 hidden/aria-hidden 元素 - useEsc: 层栈只按打开顺序维护,escClosable 实时读取; 栈顶不可关闭时吞掉 Esc,不下沉误关下层 - FSelect: filterable 时 combobox 语义与 aria 关联移到内部 input; 已输入过滤文本时不劫持 Home/End;高亮项滚动定位(虚拟列表走 scrollToIndex); 分组标题标记 role=presentation - FTabs: value 缺省回退 name,只配 name 的页签可选中/可聚焦/可方向键导航 - FPopper: role 类型放宽为 string,弹层带 data-fes-focus-scope 标记 - 测试: a11y.spec.ts 断言强化并新增 14 个用例(jsdom 尺寸打桩 覆盖真实焦点圈闭分支,去掉无效的 appendToContainer 传参) - 文档: 补齐 Popper role 与 Select/Tabs/Modal/Drawer/Switch 无障碍说明 验证:单测 2553/2553 通过(229 文件),e2e 105/105 通过 Signed-off-by: harrywan <harrywan@webank.com>
wanchun
force-pushed
the
feat/aria-a11y
branch
from
October 8, 2026 06:27
ef0a08b to
4f0fe88
Compare
- 新增 useInertBackground:弹层打开时给 body 下不属于栈顶弹层的兄弟
节点加 inert + aria-hidden="true",关闭后按原值还原,补齐
aria-modal 要求的背景隔离
- 自身带 aria-live / role=alert 的播报容器、带 data-fes-focus-scope
的浮层内容不隔离,保证 Message 朗读与弹层内下拉面板可用
- 只按节点自身判断,避免「应用根节点内含 role=alert 表单错误」
导致整个根节点被豁免、隔离静默失效
- 与 focus trap 的顺序:关闭/卸载时先摘 inert 再归还焦点,
否则 focus() 作用在 inert 子树内会静默失败
- FFormItem:错误节点带 id,经 FORM_ITEM_INJECTION_KEY 注入 errorId,
无错误信息时注入 undefined,避免 aria-describedby 指向不存在的元素
- Input(含 textarea/InputInner)、Select、Switch 绑定 aria-describedby
- 测试:a11y.spec.ts 从 28 个用例补到 40 个,含背景隔离、属性还原、
live region 与浮层豁免、多层弹层、焦点归还顺序、错误关联建立与解除;
负向校验回退源码后有 10 个用例失败
- 文档:Modal / Drawer / Form 补背景隔离与错误信息关联说明
验证:单测 2565/2565 通过(229 文件),e2e 105/105 通过
Signed-off-by: harrywan <harrywan@webank.com>
wanchun
force-pushed
the
feat/aria-a11y
branch
from
October 8, 2026 07:14
8844804 to
8340ccb
Compare
消息容器此前没有任何 live 语义,读屏完全不播报。 - createManager 支持 role / ariaLive 选项,标记落在容器本身 (getContainer 的直接子节点),而不是里层 wrapper - 容器先插入 DOM、内容后追加,保证 live region 先注册再播报 - 挂在里层 wrapper 上会被弹层背景隔离 inert 掉,读屏听不到 - aria-atomic=false:新增一条只朗读自己,不重读已在屏上的消息 - FMessage 传 role=status + aria-live=polite,短暂提示不打断朗读 - 测试:a11y.spec.ts 补 3 个用例,含弹层打开时消息容器不被背景隔离 - 文档:message 补「无障碍」小节,说明自定义 getContainer 的注意事项 验证:单测 2568/2568 通过(229 文件) Signed-off-by: harrywan <harrywan@webank.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
对比 naive-ui / element-plus / ant-design-vue 的专项研究发现:全库 67 个组件仅 collapse 有 aria 语义,且 popper 给所有弹层硬编码
role="tooltip"——Select 下拉被读屏器当作提示气泡直接跳过(错误标注比没有更糟)。本 PR 补齐核心交互链路的 a11y 基础。改动内容
一、FPopper role 参数化(修复错误标注)
role="tooltip",新增roleprop(默认不输出)role="tooltip"二、FModal/FDrawer 对话框语义 + 焦点管理
参考 element-plus el-focus-trap / antd vc-dialog:
role="dialog"+aria-modal+aria-labelledby(标题 useId 关联)useFocusTrap:打开时初始聚焦、Tab 圈闭、关闭后焦点归还;SSR 安全aria-label(新增三语言包 modal.close / drawer.close)三、修 useEsc 多弹窗 bug
[open, escClosable]联合 watch,仅打开期间监听四、FSelect 键盘化 + combobox 语义
参考 antd vc-select:
role="combobox"+ aria-expanded/controls/activedescendantrole="listbox",选项role="option"+ aria-selected + id五、FSwitch / FTabs / FForm 语义
role="switch"+ aria-checked + Space/Enter 键盘触发aria-labelledby关联;错误role="alert"验证
a11y.spec.ts12 用例:ARIA 语义断言 + 键盘链路 + 焦点圈闭 + 多弹窗 Esc不在本次范围(后续 PR)