如何停止 NVDA 读出数组中存在的 HTML 元素的列表编号(1 of 2)

发布于 2025-01-09 09:04:30 字数 174 浏览 0 评论 0原文

我正在使用 NVDA 屏幕阅读器进行辅助功能测试。同样,我有 2 个按钮/链接,它们是上下文菜单的一部分,因此存在于数组中,如“提交”和“删除”。现在其中一个按钮有 aria-label="Submit Button"。 NVDA 正在读取“提交按钮 1 of 2”。我只是想确保 NVDA 不会读取 2 中的 1。请提供同样的帮助。

I'm using NVDA screen reader for my accessibility testing. In the same, I have 2 buttons/links which are part of a context menu and thus are present inside an array say "Submit" and "Delete". Now one of the buttons has aria-label="Submit Button". And NVDA is reading "Submit Button 1 of 2". I just want to make sure that NVDA doesn't read 1 of 2. Please help with the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掩耳倾听 2025-01-16 09:04:30

NVDA 对数组或您用于编码的语言一无所知。它了解的是语义 HTML 元素。因此,如果您的按钮或链接位于列表内(

      ),或者这些按钮本身就是某个组的一部分,例如单选按钮组 (),那么 NVDA 宣布集合中的项目编号是绝对正确的。

如果您使用 ARIA 属性,例如 aria-setsizearia-posinset,但这些属性并没有被大量使用,所以我猜不是那样的。

听到“1 of 2”是屏幕阅读器的一个很棒的功能,它可以让用户了解集合有多大以及它们在集合中的哪个项目。有视力的用户通过眼睛获取这些信息。您不想删除该功能,除非您滥用分组功能并且该按钮实际上并不是组的一部分。

宣布小组立场的不同方式的示例。

使用列表

<ul style="list-style: none;">
  <li>
    <button>first button</button>
  </li>
  <li>
    <button>second button</button>
  </li>
  <li>
    <button>third button</button>
  </li>
</ul>

我可以使用 role="list"role="listitem" 而不是使用真正的

    并获得相同类型的“1 of 2”消息。

使用单选按钮

<label>
  <input type="radio" name="groupName">
  first button
</label>
<br>
<label>
  <input type="radio" name="groupName">
  second button
</label>
<br>
<label>
  <input type="radio" name="groupName">
  third button
</label>

使用 ARIA 集

<div aria-setsize="3">
  <button aria-posinset="1">first button</button>
  <button aria-posinset="2">second button</button>
  <button aria-posinset="3">third button</button>
</div>

请注意,不同的屏幕阅读器可能以不同的方式播报一组内容。有些人会说“1 of 2”,有些人可能只是说这是一个组(没有数字)。它还取决于您如何导航到按钮,是通过 TAB 还是通过向上/向下箭头键来遍历 DOM。

但这里的教训是,如果您有一组事物并且编码正确,那么您希望屏幕阅读器宣布组信息。如果您的按钮实际上并不是组的一部分,但您仍然听到组信息,那么您的代码中存在错误。如果您可以发布一些代码,可能会有所帮助。

NVDA doesn't know anything about arrays or the language you're using to code in. What it does know about is semantic HTML elements. So if you have your buttons or links inside of a list (<ul> or <ol>) or if the buttons are natively part of a group such as a radio button group (<input type="radio" name="groupName">), then it's absolutely correct for NVDA to announce the item number within the set.

You can also get "1 of 2" announced if you're using ARIA attributes such as aria-setsize and aria-posinset, but those attributes aren't heavily used so I'm guessing it's not that.

Hearing "1 of 2" is a fantastic feature of screen readers to give the user an idea of how big a set is and which item they're on in the set. Sighted users get that information with their eyes. You don't want to take that feature away unless you are misusing a grouping feature and the button isn't really part of a group.

Examples of different ways to get the group position announced.

Using lists

<ul style="list-style: none;">
  <li>
    <button>first button</button>
  </li>
  <li>
    <button>second button</button>
  </li>
  <li>
    <button>third button</button>
  </li>
</ul>

Instead of using a real <ul>, I could use role="list" and role="listitem" and get the same type of "1 of 2" messages.

Using radio buttons

<label>
  <input type="radio" name="groupName">
  first button
</label>
<br>
<label>
  <input type="radio" name="groupName">
  second button
</label>
<br>
<label>
  <input type="radio" name="groupName">
  third button
</label>

Using ARIA sets

<div aria-setsize="3">
  <button aria-posinset="1">first button</button>
  <button aria-posinset="2">second button</button>
  <button aria-posinset="3">third button</button>
</div>

Note that different screen readers may announce groups of things differently. Some will say "1 of 2", some might just say it's a group (without the number). It also depends how you navigate to the button, whether via TAB or the up/down arrow keys to walk the DOM.

But the lesson here is that if you have a group of things and it's properly coded, then you want the screen reader to announce the group info. If your buttons are not really part of a group but you're still hearing group info, then you have a bug in your code. It may help if you can post some of your code.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文