# Accessibility

> What was tested for WCAG 2.2 AA in Birch UI Document Editor, how it was tested, the keyboard map, and the known exceptions.

This page states what was checked and how. The checks are Playwright tests in `e2e/tests/document-a11y.spec.ts` and `e2e/tests/document-announce.spec.ts` and run in Chrome and Firefox; the shortcut list is on [Keyboard and accessibility](https://docs.birchui.com/document/keyboard.md).

The [conformance report](https://docs.birchui.com/document/accessibility-conformance.md) lists every WCAG 2.2 A and AA criterion with its status. The roles the editing surface exposes (page groups named *Page N of M*, headings, lists, tables, pictures, `ins` and `del`, and `aria-details` from commented and changed text to a description of the comment or change) are checked through accessibility-tree snapshots in `e2e/tests/document-a11y-tree.spec.ts`; touch and on-screen keyboard behaviour in `e2e/tests/document-mobile.spec.ts`. No screen-reader session has been run.

## Read aloud

**View → Read aloud** (<kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Space</kbd>) reads the document from the cursor, sentence by sentence, with the speech synthesis of the browser, and marks the sentence that is being read. The same key or button, or <kbd>Esc</kbd>, stops it. Text that is marked as deleted is skipped. The option and method names are those of the PDF viewer.

```ts
declare function speak(text: string): Promise<void>;

const handle = editor.readAloud({ fromPage: 0, lang: 'en-GB', rate: 1.1 });
handle.pause();
handle.resume();
handle.stop(); // or editor.stopReadAloud()
await handle.finished;

// Speak with your own voice service instead of the browser: the next sentence follows when the promise settles.
createDocumentEditor(host, {
  readAloud: {
    onText: async ({ text, pageIndex, from, to }) => {
      await speak(text);
    },
  },
});
```

`readAloud()` throws when there is neither a callback nor speech synthesis in the browser; the button is then disabled. The event `readAloudChange` carries `{ reading, paused }`. A pause takes effect after the sentence that is being spoken through a callback. The voice is the default voice of the browser for the language; there is no voice list, and words are not marked one by one.

## Accessibility checker

**Review → Check accessibility** opens a pane that lists what would make the document hard to use with a screen reader or with low vision. `checkAccessibility(rules?)` returns the same list, and `checkAccessibility(doc)` from `@birchui/document` runs it on document JSON without an editor.

| Rule | Reported when | Fix offered in the pane |
| --- | --- | --- |
| `missingAltText` | A picture, chart, diagram or shape without text has no alternative text and is not marked as decorative | **Add alternative text** opens the Alt text dialog; **Mark as decorative** for a picture |
| `skippedHeading` | A heading is more than one level below the heading before it, or the first heading is not level 1 | **Make it heading N** |
| `tableHeader` | A table with two or more rows has no header cell in its first row | **Use the first row as header** |
| `lowContrast` | Text with a colour of its own has a contrast below 4.5 to 1 with its highlight, paragraph shading, cell fill or the white page (3 to 1 from 18 pt, or from 14 pt bold) | **Use the automatic colour** |

Each entry selects its place in the document, the list follows the document as it changes, and the count is announced to screen readers. The arrow keys move between entries and <kbd>Tab</kbd> reaches the fix buttons.

```ts
const issues = editor.checkAccessibility(); // [{ id, rule, from, to, text, level?, expected?, color?, background?, ratio? }]
editor.exec('accessibilityPane');
```

A picture marked as decorative is saved with Word's decorative flag and read back from it. The checker does not look at reading order of floating objects, table structure beyond the header row, link text, document language or the contrast of pictures.

## What is tested

| Area | Check |
| --- | --- |
| Keyboard only | With no mouse: reach each of the six ribbon tabs with <kbd>Alt</kbd>+<kbd>F10</kbd> and the arrow keys and run one command in each (bold, page break, page setup dialog, footnote, track changes, navigation pane). |
| Menus and galleries | Open the line spacing menu and the styles gallery from the keyboard, choose an item, and close with <kbd>Escape</kbd>; focus returns to the button that opened them. |
| Dialogs | The paragraph dialog is `aria-modal`; forty presses of <kbd>Tab</kbd> never leave it, and <kbd>Escape</kbd> returns focus to the control that opened it. |
| Regions | <kbd>F6</kbd> moves from the document to the ribbon, the ruler, an open pane, the comments panel and back; <kbd>Escape</kbd> returns to the document. |
| Comments | Add a comment with <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>M</kbd>, reply and resolve it from the keyboard. |
| Tables and forms | <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> move through table cells (and add a row after the last cell) and through the controls of a form in form mode. |
| Visible focus | After each of those steps the focused control has an outline or a focus shadow. The editing surface shows the text cursor instead. |
| Automated rules | axe-core with the WCAG 2.0, 2.1 and 2.2 A and AA rule sets on each ribbon tab, with the Navigation, Styles, Revisions and Find panes open, and with a dialog open, in the light and the dark theme: no serious or critical findings, with the two exceptions below. |
| Forced colours | With `forced-colors: active`: a pressed toggle is filled with the highlight colour and differs from an idle one in background and text colour; a focused control has a solid outline, set off from the fill of a pressed one; the selected ribbon tab is boxed and the focused tab has a thicker box; selected text has the highlight background and selected table cells an outline; insertions stay underlined and deletions struck through; a comment range has a solid underline and the comment at the cursor a double one; the page and dialogs have a border. The same states were also looked at in screenshots with a light and a dark system palette. |
| Right to left | With `rtl: true` and an Arabic paragraph: the ribbon tabs run from the right, change bars sit on the right of the text and the comments panel on the left. |
| Small screens | At 390 × 844: no horizontal scrolling, the page fits the width, every control outside the document is at least 24 × 24 px, and panes open as a bottom sheet. |
| Reduced motion | With `prefers-reduced-motion: reduce` no element or pseudo-element on the page has an animation or a transition longer than 10 ms, and no animation is running, with the comment lane and balloons shown, after moving the cursor into a comment, with a selection and the mini toolbar, with a menu open and with a dialog open. |
| Announcements | After real key presses the polite live region contains "Bold on", the style, list and table position the cursor moved to, "Page 2 of 3, section 2" on a new page, and the author and date of the tracked change or comment the cursor entered. Typing a sentence and moving with the arrow keys inside a paragraph announce nothing, three quick toggles are announced once, and the option turns the groups off. |
| Accessibility tree | The roles and names a screen reader receives are asserted with accessibility-tree snapshots: the tab list "Ribbon tabs" with its six tabs, the text box "Document" with its headings, the region "Comments and tracked changes" with a list of threads and a list "Tracked changes" whose items have Accept and Reject buttons, the status bar, the polite and atomic live region, and a dialog with its heading. |
| 200% zoom | At 720 × 450 (a 1440 px window at 200%): no horizontal scrolling, no ribbon control cut off, the comment lane collapsed to icons, commands still work, and no serious axe finding. |
| Touch | With a touch screen emulated: a tap places the cursor, a native word selection reaches the editor (the browser draws its own selection handles), ribbon buttons answer taps and are at least 24 × 24 px. |
| Firefox | The whole browser suite for the editor also runs in Firefox; see below. |

## Announcements

The editor has one polite, atomic live region. Besides the results of commands (tracking on and off, page count, find results, replacements, new comments) it announces what changes at the cursor, 250 ms after the cursor or the formatting last changed, as one message:

| Group | Announced when | Examples |
| --- | --- | --- |
| `formatting` | Bold, italic, underline, strikethrough, superscript or subscript turns on or off at the cursor; the paragraph style changes; the cursor enters or leaves a list; the cursor enters a table, moves to another cell or leaves the table | "Bold on", "Italic off", "Heading 2", "Bulleted list", "Out of list", "In table, row 2 of 4, column 1 of 3", "Row 3 of 4, column 1 of 3", "Out of table" |
| `position` | The cursor moves to another page or section (page layout only) | "Page 3 of 12", and "Page 3 of 12, section 2" in a document with more than one section |
| `review` | The cursor enters a tracked change or a commented range | "Inserted by Priya Raman, 18 November", "Deleted by …", "Moved by …", "Formatting changed by …", "Comment by Daniel Mercer, 21 November", "Resolved comment by …" |

Nothing is announced for the state the editor starts with or for a document that was just loaded, while focus is outside the editor, or when the cursor moves without changing any of these states, so typing and moving through a paragraph stay silent. Several changes at once are joined into one message ("Normal. Bulleted list"). The date is the day and month in the language of the page (`lang`). All groups are on by default:

```ts
createDocumentEditor(host, { announcements: false }); // none of the three groups
const editor = createDocumentEditor(host, { announcements: { formatting: false } }); // position and review only
editor.update({ announcements: true });
```

The option does not silence the results of commands. The wording can be translated with the `document.announce.*` keys of `localeText`, for example `'document.announce.markOn': '{name} ein'` and `'document.announce.page': 'Seite {page} von {pages}'`.

## Exceptions

- **Ruler markers** (indent markers and margin boundaries) are smaller than 24 px and sit close together, as in every word processor. They rely on the "equivalent control" exception of success criterion 2.5.8: the same values can be set in the Paragraph, Tabs and Page setup dialogs, and each marker is a keyboard-operable slider.
- **Styles gallery label, dark theme.** axe reports the contrast of the "Styles" group label against the white style previews that are clipped out of view above it. The label is drawn on the ribbon background; the test asserts a ratio of at least 4.5:1 against that background instead.

## Not covered

- Screen readers were not run. Roles, names and states follow the WAI-ARIA Authoring Practices and are checked by axe, and the text of the live region is asserted in the tests, but there is no recorded NVDA, JAWS or VoiceOver session behind this page. How a screen reader speaks the announcements next to its own reading of the text was not checked.
- Forced colours were checked with the browser's emulation in Chrome, not with a Windows contrast theme.
- The checks run in Chrome and in Firefox. Safari was not used. In Firefox the print test skips the comparison with the browser's own PDF, which only Chromium can produce, and the composition and clipboard tests are Chromium-only because they need the DevTools protocol and clipboard permissions.
- Touch selection handles are the browser's own; the test uses an emulated touch screen, not a phone.
- Content you load is your responsibility: pictures need alt text (`imageAlt`, or mark them decorative), and text colours chosen by authors are not checked for contrast.

## Keyboard map

| Keys | Where | Action |
| --- | --- | --- |
| <kbd>Alt</kbd>+<kbd>F10</kbd> | Document | Focus the ribbon tabs (or the classic toolbar) |
| <kbd>Left</kbd> / <kbd>Right</kbd>, <kbd>Home</kbd> / <kbd>End</kbd> | Ribbon tabs | Switch tab |
| <kbd>Down</kbd> | Ribbon tabs | Enter the commands of the tab |
| <kbd>Left</kbd> / <kbd>Right</kbd> | Ribbon commands | Previous / next command |
| <kbd>Up</kbd> | Ribbon commands | Back to the tab |
| <kbd>Enter</kbd> | Ribbon commands | Run the command or open its menu |
| <kbd>Alt</kbd>, then letters | Document | Key tips: pick a tab, then a command |
| <kbd>F6</kbd> / <kbd>Shift</kbd>+<kbd>F6</kbd> | Anywhere | Next / previous region: document, ribbon, ruler, panes, comments |
| <kbd>Escape</kbd> | Menu, dialog, pane, ribbon | Close and return focus |
| <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> | Table | Next / previous cell |
| <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> | Form mode | Next / previous control |
| <kbd>Alt</kbd>+<kbd>Down</kbd> | Drop-down control | Open the list |
| <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>M</kbd> | Document | New comment |
| <kbd>Ctrl</kbd>+<kbd>Enter</kbd> | Comment or reply box | Post |
| <kbd>Enter</kbd> | Selected footnote reference, header or footer area | Edit it |
| Arrow keys, <kbd>Delete</kbd>, <kbd>Enter</kbd> | Ruler marker | Move, remove a tab stop, open the Tabs dialog |
