PreviewTrigger: the preview dialog has no accessible name

未关闭 适合新手
#10,917 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@therealemmanueloppong 已经在做这个了。

开始于 2026年11月5日。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
76/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
react, typescript

调研方向

从usePreviewTrigger开始,issue指出popoverProps在此处组装,并将其标签行为与useDialog进行比较。检查PreviewTrigger的现有测试以及对话框无障碍功能的测试。完成标准是:预览对话框默认将其触发器的 id 设为aria-labelledby,而显式传入的aria-label或aria-labelledby props 优先,并且测试覆盖该行为。

由索引模型根据 Issue 内容生成。

描述

accessibility bug PreviewTrigger
Provide a general summary of the issue here

The popover of a PreviewTrigger renders role="dialog" with no accessible name. axe reports aria-dialog-name (serious).

🤔 Expected Behavior?

The preview dialog is named by its trigger, as a Dialog inside a DialogTrigger is: aria-labelledby points to the trigger's id when the app gives no aria-label or aria-labelledby.

😯 Current Behavior
  • Popover sets role="dialog" when trigger === 'PreviewTrigger'. It takes its name only from its own aria-label and aria-labelledby props.
  • usePreviewTrigger returns popoverProps with id, onFocusWithin and onBlurWithin: no aria-labelledby.
  • A screen reader that moves into the preview hears an unnamed dialog.
💁 Possible Solution

In usePreviewTrigger, give the trigger an id and return 'aria-labelledby': triggerId in popoverProps, overridden by an aria-label or aria-labelledby passed to the Popover. This is what useDialog does with the DialogTrigger id.

🔦 Context

We wrap PreviewTrigger as a hover card in a design system. Until then, our hover card makes aria-label required.

🖥️ Steps to Reproduce
  1. Render <PreviewTrigger><Link href="/item">Item</Link><Popover><p>Summary</p></Popover></PreviewTrigger>.
  2. Focus the link and wait for the preview.
  3. Run axe, or inspect the popover: role="dialog", no aria-label, no aria-labelledby.
Version

react-aria-components 1.22.1

What browsers are you seeing the problem on?

Chrome

What operating system are you using?

macOS

主要语言
TypeScript
星标
16k
派生
1.6k
平均合并
4 天 3 小时
30 天内合并 PR
39

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

adobe/react-spectrum 的其他 Issue

查看 adobe/react-spectrum 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。