YUI 树控件的可访问性:如何在 Firefox 上切换到树?

发布于 2024-08-15 01:13:05 字数 886 浏览 2 评论 0原文

考虑这个显示正在运行的 YUI 树的示例:

http://developer.yahoo。 com/yui/examples/treeview/tv_edit.html

  1. 选择橙色标题(“TreeView 控件:TreeView 节点标签的内联编辑”)。
  2. 第一次点击选项卡:选择链接“在新窗口中查看示例”。
  3. 第二次点击选项卡:这将选择树内的一个锚点。

    <块引用>

    标签 0 未突出显示 http://img.skitch.com/20091218-61eqs6gcngp8ay56s1pba3jhb.png

  4. 从那里您可以使用向上/向下键在树中导航。当前项目始终以背景颜色突出显示。

    <块引用>

    标签 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

  1. Select the title in orange ("TreeView Control: Inline Editing of TreeView Node Labels").
  2. Hit tab a first time: the link "View example in new window" is selected.
  3. Hit tab a second time: this selects an anchor inside the tree.

    Label 0 not highlighted http://img.skitch.com/20091218-61eqs6gcngp8ay56s1pba3jhb.png

  4. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

夏天碎花小短裙 2024-08-22 01:13:05

对此的“修复”是在节点内部的锚点上注册一个侦听器,当锚点获得焦点以找到相应的节点时,并调用node.focus()。将以下内容添加到 treeview.js 中的 render() 即可达到目的:

var anchors = this.getEl().getElementsByTagName("a");
for (var anchorIndex = 0; anchorIndex < anchors.length; anchorIndex++) {
    var anchor = anchors[anchorIndex];
    Event.on(
        anchor,
        'focus',
        function (ev) {
            var target = Event.getTarget(ev);
            var node = this.getNodeByElement(target);
            node.focus();
        },
        this,
        true
    );
}

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 to render() in treeview.js does the trick:

var anchors = this.getEl().getElementsByTagName("a");
for (var anchorIndex = 0; anchorIndex < anchors.length; anchorIndex++) {
    var anchor = anchors[anchorIndex];
    Event.on(
        anchor,
        'focus',
        function (ev) {
            var target = Event.getTarget(ev);
            var node = this.getNodeByElement(target);
            node.focus();
        },
        this,
        true
    );
}
卖梦商人 2024-08-22 01:13:05

这对我来说完全失败了(使用谷歌浏览器),但是看看代码,树是嵌套表的聚集地——如果你认真对待可访问性,我会像瘟疫一样避免这种情况。

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.

唐婉 2024-08-22 01:13:05

当页面上可以接受焦点的元素被单击时,该节点将失去焦点。单击树中的节点将使该节点获得焦点。每个节点实例都有一个 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文