Skip to content

Document outline is not keyboard or screen reader accessible #19353

Open

Description

@gtritchie

Description

The document outline (source editor and visual editor) can't be used with a keyboard and is not correctly exposed to screen readers. An axe scan reports every outline item as "Certain ARIA roles must be contained by particular parents: Required ARIA parents role not present: group, tree".

Both outlines are built on GWT's Tree widget (DocumentOutlineWidget, PanmirrorOutlineWidget). Problems:

  • Items are outside the tree. GWT's Tree puts role="tree" on a hidden 0×0 focusable <div>, and the treeitem elements are its siblings rather than its children. Its aria-activedescendant therefore points at elements outside the tree, which is invalid, so screen readers may not announce the current item.
  • The tree has no accessible name. The outlines set aria-label on the Tree's outer <div>, which has no role, not on the role="tree" element.
  • No visible focus. After tabbing in, the focused element is 0×0 and drawn behind the outline's background (z-index: -1). Arrow keys move the selection, but the selected item (gwt-TreeItem-selected) has no style.
  • No keyboard activation. Navigation is wired to a click handler only. Enter and Space on an item do nothing.
  • Heading levels are lost. The outline is a flat list of top-level items, with indentation faked with &nbsp;. Every item reports aria-level=1, so H1/H2/H3 structure isn't conveyed.

Relevant WCAG 2.2 criteria: 1.3.1 Info and Relationships, 2.1.1 Keyboard, 2.4.7 Focus Visible, 4.1.2 Name, Role, Value.

Steps to reproduce

  1. Open a Markdown file with several heading levels, e.g.
    # H1
    ## H2
    ### H3
    ## H2.1
    
  2. Show the outline (the Outline button in the editor toolbar).
  3. Run an axe scan, then press Tab until focus reaches the outline, press Down Arrow, then Enter.

Expected

The outline follows the WAI-ARIA tree view pattern: a named tree whose items convey their heading level, a visible focus indicator on the focused item, Up/Down/Home/End to move between items, and Enter to move the editor cursor to that section.

Actual

axe reports aria-required-parent for every item. No focus indicator is visible on Tab or after arrow keys, and Enter/Space do nothing (the cursor stays where it was). Screen readers get an unnamed, empty tree.

Proposed fix

Replace Tree in both outlines with a small shared RStudio outline widget:

  • role="tree" and the accessible name on the container that holds the items
  • each item a treeitem with aria-level taken from its section depth (plus aria-setsize/aria-posinset)
  • roving tabindex on the items, so focus is real DOM focus and the standard focus-visible styling applies
  • Up/Down/Home/End to move; Enter/Space to navigate the editor, matching the existing click behaviour

Both outlines already flatten their content into a list and don't use Tree's nesting or expand/collapse. The hidden-focusable design in GWT's Tree causes the parent-role and focus problems, so it's simpler to replace than to patch in our GWT fork. These two outlines are the only live Tree uses in RStudio. ScopeTreeWidget also uses it but is unreferenced dead code, and can be removed in the same change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions