简体   繁体   English

如何根据搜索框中输入的文本通知用户建议列表已到达

[英]How to announce user that suggestions list has arrived corresponding to the text entered in searchbox

I am having a autocomplete list with manual selection means that:我有一个带有手动选择的自动完成列表意味着:

When the suggestions box/list is displayed, it contains suggested values that correspond to the characters typed in the textbox.当显示建议框/列表时,它包含与文本框中键入的字符相对应的建议值。 In my implementation, the values in the listbox have names that start with the characters typed in the textbox.在我的实现中,列表框中的值的名称以文本框中键入的字符开头。

Users can set the value of the searchbox by choosing a value from the suggestions list.用户可以通过从建议列表中选择一个值来设置搜索框的值。

If the user does not choose a value from the suggestions list before moving focus outside the searchbox, the value that the user typed, if any, becomes the value of the searchbox.如果用户在将焦点移出搜索框之前没有从建议列表中选择值,则用户键入的值(如果有)将成为搜索框的值。

So my ask here is how to provide information to the visually impaired user that the suggestions list has now arrived corresponding to the text he has entered.所以我在这里的问题是如何向视障用户提供建议列表现在已经到达与他输入的文本相对应的信息。

As pointed out in the comments, the HTML datalist element would be the standard compliant way of realising a suggestion box.正如评论中指出的那样,HTML datalist 元素将是实现建议框的标准兼容方式。 It would be linked with your text input by means of the list attribute.它将通过list属性与您的文本输入链接。

<input list="ice-cream-flavors" … />

<datalist id="ice-cream-flavors">
    <option value="Chocolate">
    …
</datalist>

Sticking to HTML usually assures the most robust support of accessibility in the long term, and you wouldn't even need to worry about how to announce changes to this list.从长远来看,坚持使用 HTML 通常可以确保对可访问性的最强大支持,您甚至无需担心如何宣布对此列表的更改。

But, as of now, it seems that the most popular screen readers are not announcing changes to the suggestions , so you might want another solution.但是,截至目前,似乎最流行的 屏幕阅读器并未宣布对建议的更改,因此您可能需要其他解决方案。

The ARIA Authoring Practices provide some guidelines on how to build search suggestions. ARIA 创作实践提供了一些关于如何构建搜索建议的指南。 The pattern is called Combobox , and the corresponding autocomplete behaviour would be "List autocomplete with manual selection".该模式称为Combobox ,相应的自动完成行为将是“手动选择列表自动完成”。

The following line from that document should answer your question:该文档中的以下行应该可以回答您的问题:

When the combobox popup is not visible, the element with role combobox has aria-expanded set to false.当组合框弹出窗口不可见时,具有组合框角色的元素将 aria-expanded 设置为 false。 When the popup element is visible, aria-expanded is set to true.当弹出元素可见时,aria-expanded 设置为 true。 Note that elements with role combobox have a default value for aria-expanded of false.请注意,具有角色组合框的元素的 aria-expanded 的默认值为 false。

From Aria roles and states咏叹调角色和状态

Screenreaders usually announce changes to this attribute.屏幕阅读器通常会宣布对此属性的更改。

You might notice that besides this attribute, there are quite some other attributes and roles to use, and keyboard navigation to implement, to really make the component accessible.您可能会注意到,除了这个属性之外,还有很多其他属性和角色要使用,键盘导航要实现,才能真正使组件可访问。

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

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