自定义上下文菜单是否可访问?

Are custom context menu accessible?

在 table 中单击 <tr> 时,我想显示记录上的可用操作,而不是额外的 "actions" 列。

根据可访问性标准,自定义上下文菜单是否被视为可访问?

可以以可访问的方式呈现上下文菜单。它可能会产生一些额外的工作。

来自Web Accessibility: "Standalone, attached, and context menus"

In the HTML specification, no component exists that allows developers to define either context or attached menus. Most often, developers implement menu functionality through a series of layers dynamically shown and positioned via JavaScript. This results in a menu system that is readily usable via the mouse, but can be difficult to use from the keyboard. Furthermore, accessing the menu structure involves significant client side content changes, which tend to be supported poorly in assistive technology.

To address these issues, developers must ensure that attached menus are clearly indicated to the user and that all menus function properly from the keyboard. For principal elements that include attached menus, its textual representation should include a clear phrase such as "menu attached". This indicates to the user that an attached menu is present and it can be accessed in the standard fashion for the form. For form elements, this can be accomplished in the standard methods of explicit labeling, either via the title attribute or the label element. If a separate element is used to trigger the attached menu, the triggering element's textual representation should include the name of the principal element so that it is explicit what the menu relates to.

有关使上下文菜单可访问的更多详细信息和指南,请参阅链接网站。

您能做的最好的事情就是提供一个额外的按钮来打开菜单

此按钮必须完全可见(对于触摸屏、眼动追踪设备)、完整描述(对于屏幕阅读器),并且可以通过键盘和鼠标完全操作。

如果没有视觉和明确的信息表明 click/keypress 将打开一个无法访问的菜单。

您也可以在完整的 tr 中添加一个 "right click" 事件以打开菜单以实现最快的操作,但它应该用作按钮的补充,并且更符合人体工程学而不是比无障碍。