Skip to content

a11y: revealjs scrollable code blocks cannot be scrolled by keyboard #14817

Description

@cwickham

Split from #14378, which covers format: html only.

WCAG: 2.1.1 Keyboard (A), 2.1.3 Keyboard, No Exception (AAA)
axe rule: scrollable-region-focusable — reports the .scrollable slide and the reveal-menu .active-menu-panel, but not the code blocks. The code-block half of this issue is invisible to axe; see below.
Targets: .reveal pre code, .scrollable slides, reveal-menu .active-menu-panel

Repro:

---
title: "Scrollable regions in revealjs"
format: revealjs
---

## Wide code block

```python
wide_code = "an_unbroken_token_that_cannot_wrap_and_overflows_the_slide_width_easily"
```

## Tall code block

```python
line_01 = "padding"
line_02 = "padding"
line_03 = "padding"
line_04 = "padding"
line_05 = "padding"
line_06 = "padding"
line_07 = "padding"
line_08 = "padding"
line_09 = "padding"
line_10 = "padding"
line_11 = "padding"
line_12 = "padding"
line_13 = "padding"
line_14 = "padding"
line_15 = "padding"
line_16 = "padding"
line_17 = "padding"
line_18 = "padding"
line_19 = "padding"
line_20 = "padding"
line_21 = "padding"
line_22 = "padding"
line_23 = "padding"
line_24 = "padding"
line_25 = "padding"
```

## Scrollable slide {.scrollable}

- item one
- item two
- item three
- item four
- item five
- item six
- item seven
- item eight
- item nine
- item ten
- item eleven
- item twelve
- item thirteen
- item fourteen
- item fifteen
- item sixteen
- item seventeen
- item eighteen
- item nineteen
- item twenty

Code blocks

theme.scss gives .reveal pre code overflow: auto; max-height: 400px. The scroll container is therefore the code element, not the div.sourceCode wrapper as in HTML output. At 390x844 the wide block hides 192px to the right and the tall block hides 215px below; div.sourceCode and pre both measure 0 overflow.

A keyboard user cannot reach that hidden content. Tabbing into the wide block lands on the line-number link for line 1 and leaves scrollLeft at 0, so all 192px stay clipped.

Why axe stays silent. revealjs turns on code line numbers by default. Pandoc emits a real fragment link per numbered line (<a href="#cbN-n">), which is focusable by design — it is how a reader links to a line. Without line numbers Pandoc instead emits a decorative anchor carrying aria-hidden="true" tabindex="-1". scrollable-region-focusable passes any scrollable region containing focusable content, so a numbered block satisfies the rule.

The rule is satisfied, but the region still cannot be scrolled. Line anchors sit at the start of each line, so focusing one never moves the region horizontally: measured scrollLeft stays 0 with 192px still clipped. Vertical overflow fares better, since tabbing down the anchors does scroll the block, at a cost of one tab stop per line (25 for the block above).

The focusable anchors are deliberate and are not the bug here. #14655 (fa5f81c) added aria-label to them and explicitly rejected aria-hidden, "since these anchors are real, focusable fragment links, and aria-hidden on a focusable element is itself an accessibility violation." Any fix should keep them focusable.

Scrollable slides and the menu panel

A .scrollable slide is reported by axe (#scrollable-slide), as are body and #slide-N on several quarto-web decks, and the reveal-menu .active-menu-panel at both 390x844 and 1440x900.

Constraints

  • revealjs binds the arrow keys to slide navigation, so making a region focusable is not sufficient on its own — the keys that scroll it must not fight slide navigation.
  • revealjs: off-screen slides stay in the keyboard tab order (Tab from slide N lands on slide N-2) #14795 (off-screen slides stay tabbable) interacts directly. Adding tabindex="0" to scrollers on .past and .future slides would add more phantom tab stops, while the inert fix proposed there would neutralize them. These two want fixing together, or in that order.

Related: #14710 (same rule, the axe report UI on revealjs and dashboard), #14249 (same vendored slide-menu component, different rule), #13574 (prior a11y work on revealjs code line numbers).

Part of #8706.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions