YUI 树控件的可访问性:如何在 Firefox 上切换到树?
考虑这个显示正在运行的 YUI 树的示例:
http://developer.yahoo。 com/yui/examples/treeview/tv_edit.html
- 选择橙色标题(“TreeView 控件:TreeView 节点标签的内联编辑”)。
- 第一次点击选项卡:选择链接“在新窗口中查看示例”。
第二次点击选项卡:这将选择树内的一个锚点。
<块引用>标签 0 未突出显示 http://img.skitch.com/20091218-61eqs6gcngp8ay56s1pba3jhb.png
从那里您可以使用向上/向下键在树中导航。当前项目始终以背景颜色突出显示。
<块引用>标签 1 突出显示 http://img.skitch.com/20091218-es5xh4g4k41d8s133hay65ufrr.png
问题在于,当前项目的背景在上面的步骤 3 中未突出显示(但在步骤 4 的树中导航时突出显示)。这是 YUI 树的错误,还是有一种方法可以在树接收焦点时以编程方式突出显示当前项目?
Consider this example showing the YUI tree in action:
http://developer.yahoo.com/yui/examples/treeview/tv_edit.html
- Select the title in orange ("TreeView Control: Inline Editing of TreeView Node Labels").
- Hit tab a first time: the link "View example in new window" is selected.
Hit tab a second time: this selects an anchor inside the tree.
Label 0 not highlighted http://img.skitch.com/20091218-61eqs6gcngp8ay56s1pba3jhb.png
From there you can use the up/down keys to navigate through the tree. The current item is always highlighted with a background color.
Label 1 is highlighted http://img.skitch.com/20091218-es5xh4g4k41d8s133hay65ufrr.png
The issue is that the background of the current item is not highlighted on step 3 above (but it is when navigating through the tree on step 4). Is this a bug of the YUI tree, or is there a way to programmatically highlight the current item when the tree receives the focus?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对此的“修复”是在节点内部的锚点上注册一个侦听器,当锚点获得焦点以找到相应的节点时,并调用
node.focus()
。将以下内容添加到treeview.js
中的render()
即可达到目的:A "fix" for this is to register a listener on anchors inside the node, when an anchor gets the focus to find the corresponding node, and call
node.focus()
. Adding the following torender()
intreeview.js
does the trick:这对我来说完全失败了(使用谷歌浏览器),但是看看代码,树是嵌套表的聚集地——如果你认真对待可访问性,我会像瘟疫一样避免这种情况。
This fails for me entirely (using Google Chrome), but looking at the code the tree is a warren of nested tables - I'd avoid this like the plague if you're serious about accessibility.
当页面上可以接受焦点的元素被单击时,该节点将失去焦点。单击树中的节点将使该节点获得焦点。每个节点实例都有一个 focus() 方法,因此您可以随时手动聚焦树中的任何节点 - 这正是该示例为突出显示第二个节点所做的操作。
The node will lose focus when element on the page that can accept focus is clicked. Clicking on a node in the tree will give that node focus. Every node instance has a focus() method, so you can manually focus any node in the tree whenever you like -- this is exactly what that example is doing to highlight the second node.