简体   繁体   English

HTML 可访问性 combobox 角色

[英]HTML accessibility combobox role

I have the following layout in my project:我的项目中有以下布局:

<div class="css-c18mwd-ImageFrameBase-ImageFrameWithGradient-SecondaryImageFrameWithGradient e1jjxv8j4">
<button tabindex="0" aria-haspopup="true" class="css-11ubmv-MediaGridButton e1jjxv8j1">Enlarge Nordic Blue Nokia X20 from Front and Back</button>
</div>

But when I review the accessibility tab, it says that the role for my button is combobox as shown in the screenshot below.但是当我查看辅助功能选项卡时,它显示我的button的角色是combobox ,如下面的屏幕截图所示。

How can I change it to be more accessible and have a role of button like the other buttons on the page?如何将其更改为更易于访问并像页面上的其他button一样具有按钮的作用?

可访问性树

That's a curious case.这是一个奇怪的案例。 I believe you should remove aria-haspopup (and tabindex while you're at it, that's redundant for <button> ).我相信你应该删除aria-haspopup (和tabindex当你在它的时候,这对于<button>是多余的)。

Just as a reminder before we continue: What counts is what screen readers announce in the end, and to be compliant with the relevant standards.就像我们继续之前的提醒一样:重要的是屏幕阅读器最终宣布了什么,并符合相关标准。

From the haspopup attribute documentation :haspopup属性文档

A popup element usually appears as a block of content that is on top of other content.弹出元素通常显示为位于其他内容之上的内容块。 Authors MUST ensure that the role of the element that serves as the container for the popup content is menu, listbox, tree, grid , or dialog , and that the value of aria-haspopup matches the role of the popup container.作者必须确保用作弹出内容容器的元素的角色是menu, listbox, tree, griddialog ,并且aria-haspopup的值与弹出容器的角色相匹配。

If I understand correctly from your comments you are opening a larger view of an image.如果我从您的评论中正确理解您正在打开图像的更大视图。 From the list above, the only fitting role would be that of dialog .从上面的列表中,唯一合适的角色是dialog

When looking at the documentation for the dialog role , you will not find any mention of haspopup , nor have I seen any dialog pattern with that attribute.在查看dialog role 的文档时,您不会发现任何提及haspopup ,我也没有看到任何具有该属性的对话框模式。

Even the Modal Dialog Example on the ARIA Authoring Practices Guide does not make use of that attribute.甚至ARIA Authoring Practices Guide 上的模态对话框示例也没有使用该属性。 Neither does the Bootstrap Modal . Bootstrap Modal也没有。

So my suggestion is to follow these guides and simply remove aria-hasdialog and make sure your dialog is implementing all requirements right.所以我的建议是遵循这些指南并简单地删除aria-hasdialog并确保您的对话正确实施所有要求。

Further, I believe that browsers are not meant to change the element's role dependent on the value in that attribute.此外,我相信浏览器并不是要根据该属性中的值来改变元素的角色。 I'm even more reassured by the fact that aria-hasdialog is deprecated except for chosen roles, and button is among them .我更放心的是aria-hasdialog已被弃用,除了选定的角色,而button就是其中之一 How would that make sense if it changed that role?如果它改变了这个角色,这有什么意义呢?

Test results试验结果

Chrome exposes the combobox role in all these cases: Chrome 在所有这些情况下都公开了combobox角色:

<button aria-haspopup="true">Enlarge Image</button>
<button aria-haspopup="true" aria-expanded="false">Enlarge Image</button>
<button aria-haspopup="dialog">Enlarge Image</button>

But Chromvox will announce:但 Chromvox 将宣布:

Enlarge image, popup button放大图片,弹出按钮
Enlarge image, popup button collapsed放大图像,弹出按钮折叠
Enlarge image, button放大图像,按钮

I haven't tested with NVDA yet, if anybody could test with Jaws that would be great.我还没有用 NVDA 测试过,如果有人可以用 Jaws 测试那就太好了。

Firefox makes a difference, but changes the role as well for the first two, which seems appropriate. Firefox 有所不同,但也改变了前两个的角色,这似乎很合适。

Maybe we should file a bug report with the Webkit team.也许我们应该向 Webkit 团队提交错误报告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM