[英]How to handle focus and define ARIA roles
In the 1001st implementation of carousel I would like to "properly" handle the focus.在轮播的第 1001 次实现中,我想“正确”处理焦点。 The cyan arrow buttons are fine.
青色箭头按钮很好。 They have role="button".
他们有角色=“按钮”。
A few quick questions related to UI/UX of this component:一些与此组件的 UI/UX 相关的快速问题:
element.focus()
method - like pure HTML/CSS solution?element.focus()
方法来做到这一点 - 就像纯 HTML/CSS 解决方案一样?element.focus()
? element.focus()
可行吗? What should be ARIA role for this component?:focus
selector):focus
选择器)Regarding focus, you ask if the focus can be kept on the buttons without using focus()
.关于焦点,您询问是否可以在不使用
focus()
情况下将focus()
保持在按钮上。 Absolutely.绝对地。 In fact, when you click on a button, the focus will not move unless you specifically move it or if the element you clicked on gets hidden.
事实上,当你点击一个按钮时,焦点不会移动,除非你特意移动它或者你点击的元素被隐藏了。 So if your desire is to leave the focus on the button, then you don't have to do anything.
因此,如果您希望将焦点放在按钮上,那么您无需执行任何操作。
That's the preferred behavior - leave the focus on the button.这是首选行为 - 将焦点放在按钮上。 If I'm exploring the carousel slides and I'm a keyboard user, I will navigate/tab to the "next" button and press enter .
如果我正在浏览轮播幻灯片并且我是键盘用户,我将导航/标签到“下一步”按钮并按enter 。 I'll review the slide and if it's not what I want, I'll press enter again (assuming my focus remained on the "next" button) to see the next slide.
我将查看幻灯片,如果它不是我想要的,我将再次按Enter (假设我的注意力仍停留在“下一个”按钮上)以查看下一张幻灯片。 If you force the focus to move away from the button and to the carousel content, then I have to navigate back to the "next" button before I can view the next slide.
如果您强制焦点从按钮移到轮播内容,那么我必须导航回“下一个”按钮才能查看下一张幻灯片。 It can be annoying to have to keep navigating back to the element I just selected.
不得不继续导航回我刚刚选择的元素可能会很烦人。
I don't understand your third or fourth questions.我不明白你的第三或第四个问题。
Have you looked at the two W3.org references regarding carousels?您是否看过有关轮播的两个 W3.org 参考资料?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.