组合框是否需要具有文本框角色的子元素?

Does a combobox require a child element with the role of textbox?

我有一个组合框触发了 Accessibility for Insights 工具的辅助功能错误 (https://accessibilityinsights.io/en/downloads/). The combobox can be seen in the mobile phone field with the country flag selector here - https://configure.awardsplatform.com

这是我从 Accessibility for Insights 收到的错误消息:

Wai-aria 1.1 指南说文本框是必需的 - https://www.w3.org/TR/wai-aria-1.1/#combobox

但是,我很困惑,因为 Wai-aria 1.2 指南(显然仍在开发中)没有将其作为要求 - https://www.w3.org/TR/wai-aria-1.2/#combobox

并且此示例组合框也不包含文本框 - https://w3c.github.io/aria-practices/examples/combobox/combobox-select-only.html

这里的信息相互矛盾,所以我不确定是否需要。有人知道吗?

对“组合框是否需要具有文本框角色的子元素?”的简短回答

根据当前 (aria-1.1) 标准:

更长的答案

标准将很快发生变化,您正在查看尚未最终确定的未来指南。根据当前指南,您选择的国家/地区使用的角色不正确。

为什么会出现错误?

我们仍在使用 aria-1.1 标准。

definition of a combobox in the aria 1.1 standards是:

A composite widget containing a single-line textbox and another element, such as a listbox or grid, that can dynamically pop up to help the user set the value of the textbox.

至于 the example combobox you gave,您可能一直在查看一个用于 aria-1.2 的示例(尽管我仍然不相信它在那时是有效的,因为它仍然应该设置某种类型的值输入,但我们会看到一切何时正式发布,因为我认为“输入”的 1.2 定义仍然需要更好地定义)

目前,combobox 是一个 <input>(或等价物),带有可用于设置 <input> 值的相关列表。一个关键功能是您仍然可以手动输入值。

您应该改用什么?

对于您的示例,<select>(或 role="listbox" 等等效项)更为合适,因为用户无法手动输入国家/地区。

即使新指南出台a listbox will probably still be a better choice from the definition currently in place