@ngbracket/a11y-devtools 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to `@ngbracket/a11y-devtools` are documented here.
|
|
4
4
|
This project adheres to [Semantic Versioning](https://semver.org/).
|
|
5
5
|
|
|
6
|
+
## 0.12.2
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- **Every `ngbr/*` finding links to its own explanation.** `helpUrl` now points to
|
|
11
|
+
the rule's page in the docs (for example
|
|
12
|
+
`https://ngbracket.com/tools/a11y-devtools/docs/click-without-key`). Each page
|
|
13
|
+
explains what the message means, who it affects, exactly what triggers it, how
|
|
14
|
+
to fix it and how to check it yourself, and links the WCAG or APG reference. It
|
|
15
|
+
used to link straight to the WCAG page.
|
|
16
|
+
- **Clearer messages.** Each now starts with what's wrong for the user, in plain
|
|
17
|
+
words. `ngbr/click-without-key` no longer calls itself a "possible keyboard
|
|
18
|
+
trap": a keyboard trap means you can't Tab away, and this rule is about a
|
|
19
|
+
control you can reach but may not be able to activate. `ngbr/focus-trap` now
|
|
20
|
+
starts "Keyboard trap:", which is what it finds.
|
|
21
|
+
|
|
6
22
|
## 0.12.1
|
|
7
23
|
|
|
8
24
|
### Fixed
|
package/dist/inpage.global.js
CHANGED
|
@@ -34821,10 +34821,7 @@
|
|
|
34821
34821
|
"treeitem"
|
|
34822
34822
|
]);
|
|
34823
34823
|
var KEY_EVENTS = ["keydown", "keyup", "keypress"];
|
|
34824
|
-
var
|
|
34825
|
-
var KEYBOARD_URL = `${UNDERSTANDING}/keyboard.html`;
|
|
34826
|
-
var FOCUS_ORDER_URL = `${UNDERSTANDING}/focus-order.html`;
|
|
34827
|
-
var DIALOG_MODAL_URL = "https://www.w3.org/WAI/ARIA/apg/patterns/dialog-modal/";
|
|
34824
|
+
var RULE_DOCS = "https://ngbracket.com/tools/a11y-devtools/docs";
|
|
34828
34825
|
function shortSelector(element) {
|
|
34829
34826
|
const tag = element.tagName.toLowerCase();
|
|
34830
34827
|
if (element.id)
|
|
@@ -34872,21 +34869,21 @@
|
|
|
34872
34869
|
const focusable = isTabbable(element, isVisible);
|
|
34873
34870
|
if (!focusable) {
|
|
34874
34871
|
const reason = interactiveByRole ? `has role="${role}"` : "has a click handler";
|
|
34875
|
-
findings.push(make(element, "ngbr/unreachable-control", "serious", `
|
|
34872
|
+
findings.push(make(element, "ngbr/unreachable-control", "serious", `Keyboard users can't reach this control: it ${reason}, but it isn't a native control and has no tabindex="0", so Tab skips it. Use a <button> or <a href>, or add tabindex="0" and Enter/Space handling.`, `${RULE_DOCS}/unreachable-control`));
|
|
34876
34873
|
continue;
|
|
34877
34874
|
}
|
|
34878
34875
|
const hasKey = events.some((e) => KEY_EVENTS.includes(e));
|
|
34879
34876
|
if (hasClick && !hasKey) {
|
|
34880
|
-
findings.push(make(element, "ngbr/click-without-key", "moderate", `
|
|
34877
|
+
findings.push(make(element, "ngbr/click-without-key", "moderate", `Keyboard users may not be able to activate this: Tab reaches it, but it only listens for click, and Enter and Space don't fire click on a non-native element. Use a <button>, or handle Enter and Space too. Heuristic \u2014 verify manually.`, `${RULE_DOCS}/click-without-key`));
|
|
34881
34878
|
}
|
|
34882
34879
|
}
|
|
34883
34880
|
for (const modal2 of findUncontainedModals(root, { frameworkPrefixes: prefixes, isVisible })) {
|
|
34884
|
-
findings.push(make(modal2.element, "ngbr/modal-focus-not-contained", "moderate", `
|
|
34881
|
+
findings.push(make(modal2.element, "ngbr/modal-focus-not-contained", "moderate", `Keyboard users can Tab out of this modal: it has aria-modal="true", but ${modal2.outsideCount} control(s) outside it can still be reached with Tab. Open it with <dialog>.showModal(), make the rest of the page inert, or trap focus. Heuristic \u2014 verify manually.`, `${RULE_DOCS}/modal-focus-not-contained`));
|
|
34885
34882
|
}
|
|
34886
34883
|
const stops = tabSequence(root, { frameworkPrefixes: prefixes, isVisible, isModal: options.isModal });
|
|
34887
34884
|
for (const jump of visualOrderJumps(stops)) {
|
|
34888
34885
|
const stop = stops[jump];
|
|
34889
|
-
findings.push(make(stop.element, "ngbr/tab-order-mismatch", "moderate", `
|
|
34886
|
+
findings.push(make(stop.element, "ngbr/tab-order-mismatch", "moderate", `Tab order jumps backwards here: Tab reaches this control (stop ${stop.order}) after one that sits below it or to its right, so focus moves against the reading order. Heuristic \u2014 check the order makes sense to a sighted keyboard user.`, `${RULE_DOCS}/tab-order-mismatch`));
|
|
34890
34887
|
}
|
|
34891
34888
|
return findings;
|
|
34892
34889
|
}
|
|
@@ -34916,7 +34913,7 @@
|
|
|
34916
34913
|
}
|
|
34917
34914
|
return { kind: "pending" };
|
|
34918
34915
|
}
|
|
34919
|
-
var
|
|
34916
|
+
var FOCUS_TRAP_DOCS = "https://ngbracket.com/tools/a11y-devtools/docs/focus-trap";
|
|
34920
34917
|
function deepActiveElement(doc) {
|
|
34921
34918
|
let active = doc.activeElement;
|
|
34922
34919
|
while (active?.shadowRoot?.activeElement)
|
|
@@ -34978,8 +34975,8 @@
|
|
|
34978
34975
|
return {
|
|
34979
34976
|
id: "ngbr/focus-trap",
|
|
34980
34977
|
impact: shiftTabEscapes ? "moderate" : "serious",
|
|
34981
|
-
help: `
|
|
34982
|
-
helpUrl:
|
|
34978
|
+
help: `Keyboard trap: ${where}${reach}.${shift} If this widget deliberately keeps Tab (e.g. a code editor), it must tell users how to leave (such as Escape); otherwise let Tab move focus on. Found by real Tab presses \u2014 verify manually.`,
|
|
34979
|
+
helpUrl: FOCUS_TRAP_DOCS,
|
|
34983
34980
|
component: appComponentFromPath(componentPath, frameworkPrefixes),
|
|
34984
34981
|
componentPath,
|
|
34985
34982
|
directives: resolveDirectiveNames(owner),
|
|
@@ -56,7 +56,8 @@ export function detectTabTrap(observations, collapsible = new Set()) {
|
|
|
56
56
|
}
|
|
57
57
|
return { kind: 'pending' };
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
/** The rule's page: what the message means, how to fix and check it, and WCAG 2.1.2. */
|
|
60
|
+
const FOCUS_TRAP_DOCS = 'https://ngbracket.com/tools/a11y-devtools/docs/focus-trap';
|
|
60
61
|
/** The element that really has focus, through open shadow roots. */
|
|
61
62
|
function deepActiveElement(doc) {
|
|
62
63
|
let active = doc.activeElement;
|
|
@@ -132,10 +133,10 @@ export function createFocusWalkProbe(doc = document, frameworkPrefixes = DEFAULT
|
|
|
132
133
|
return {
|
|
133
134
|
id: 'ngbr/focus-trap',
|
|
134
135
|
impact: shiftTabEscapes ? 'moderate' : 'serious',
|
|
135
|
-
help: `
|
|
136
|
+
help: `Keyboard trap: ${where}${reach}.${shift} If this widget deliberately keeps ` +
|
|
136
137
|
`Tab (e.g. a code editor), it must tell users how to leave (such as Escape); otherwise ` +
|
|
137
138
|
`let Tab move focus on. Found by real Tab presses — verify manually.`,
|
|
138
|
-
helpUrl:
|
|
139
|
+
helpUrl: FOCUS_TRAP_DOCS,
|
|
139
140
|
component: appComponentFromPath(componentPath, frameworkPrefixes),
|
|
140
141
|
componentPath,
|
|
141
142
|
directives: resolveDirectiveNames(owner),
|
|
@@ -7,6 +7,11 @@ export interface KeyboardScanOptions {
|
|
|
7
7
|
/** Modal-dialog check override (tests; jsdom has no `:modal`). See {@link tabSequence}. */
|
|
8
8
|
isModal?: (element: Element) => boolean;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Each rule's page: what the message means, who it affects, exactly what
|
|
12
|
+
* triggers it, how to fix and check it, and the WCAG/APG reference.
|
|
13
|
+
*/
|
|
14
|
+
export declare const RULE_DOCS = "https://ngbracket.com/tools/a11y-devtools/docs";
|
|
10
15
|
/** A short, human CSS-ish selector for our own findings (not an axe target). */
|
|
11
16
|
export declare function shortSelector(element: Element): string;
|
|
12
17
|
/** Truncated outerHTML for a finding's `html`. */
|
|
@@ -35,10 +35,11 @@ const INTERACTIVE_ROLES = new Set([
|
|
|
35
35
|
'treeitem',
|
|
36
36
|
]);
|
|
37
37
|
const KEY_EVENTS = ['keydown', 'keyup', 'keypress'];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Each rule's page: what the message means, who it affects, exactly what
|
|
40
|
+
* triggers it, how to fix and check it, and the WCAG/APG reference.
|
|
41
|
+
*/
|
|
42
|
+
export const RULE_DOCS = 'https://ngbracket.com/tools/a11y-devtools/docs';
|
|
42
43
|
/** A short, human CSS-ish selector for our own findings (not an axe target). */
|
|
43
44
|
export function shortSelector(element) {
|
|
44
45
|
const tag = element.tagName.toLowerCase();
|
|
@@ -105,37 +106,37 @@ export function scanKeyboard(root = document, options = {}) {
|
|
|
105
106
|
const focusable = isTabbable(element, isVisible);
|
|
106
107
|
if (!focusable) {
|
|
107
108
|
const reason = interactiveByRole ? `has role="${role}"` : 'has a click handler';
|
|
108
|
-
findings.push(make(element, 'ngbr/unreachable-control', 'serious', `
|
|
109
|
-
`
|
|
110
|
-
`
|
|
109
|
+
findings.push(make(element, 'ngbr/unreachable-control', 'serious', `Keyboard users can't reach this control: it ${reason}, but it isn't a native ` +
|
|
110
|
+
`control and has no tabindex="0", so Tab skips it. Use a <button> or <a href>, ` +
|
|
111
|
+
`or add tabindex="0" and Enter/Space handling.`, `${RULE_DOCS}/unreachable-control`));
|
|
111
112
|
continue; // don't also report a weaker click-without-key on the same node
|
|
112
113
|
}
|
|
113
114
|
// Focusable, but a bare (click) never fires on Enter/Space the way a native
|
|
114
115
|
// button does — so a keyboard user can reach it and still not activate it.
|
|
115
116
|
const hasKey = events.some((e) => KEY_EVENTS.includes(e));
|
|
116
117
|
if (hasClick && !hasKey) {
|
|
117
|
-
findings.push(make(element, 'ngbr/click-without-key', 'moderate', `
|
|
118
|
-
`
|
|
119
|
-
`
|
|
118
|
+
findings.push(make(element, 'ngbr/click-without-key', 'moderate', `Keyboard users may not be able to activate this: Tab reaches it, but it only ` +
|
|
119
|
+
`listens for click, and Enter and Space don't fire click on a non-native element. ` +
|
|
120
|
+
`Use a <button>, or handle Enter and Space too. Heuristic — verify manually.`, `${RULE_DOCS}/click-without-key`));
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
// Missing focus trap (M3): an open aria-modal whose focus isn't contained.
|
|
123
124
|
// Reuses the tab-order machinery (inert/hidden already excluded), so a modal
|
|
124
125
|
// that correctly inerts the background is not flagged.
|
|
125
126
|
for (const modal of findUncontainedModals(root, { frameworkPrefixes: prefixes, isVisible })) {
|
|
126
|
-
findings.push(make(modal.element, 'ngbr/modal-focus-not-contained', 'moderate', `
|
|
127
|
-
`${modal.outsideCount}
|
|
128
|
-
`
|
|
129
|
-
`
|
|
127
|
+
findings.push(make(modal.element, 'ngbr/modal-focus-not-contained', 'moderate', `Keyboard users can Tab out of this modal: it has aria-modal="true", but ` +
|
|
128
|
+
`${modal.outsideCount} control(s) outside it can still be reached with Tab. Open it ` +
|
|
129
|
+
`with <dialog>.showModal(), make the rest of the page inert, or trap focus. ` +
|
|
130
|
+
`Heuristic — verify manually.`, `${RULE_DOCS}/modal-focus-not-contained`));
|
|
130
131
|
}
|
|
131
132
|
// Visual-vs-tab-order mismatch: a heuristic over the resolved sequence. Needs
|
|
132
133
|
// real layout, so it no-ops where getBoundingClientRect returns zeros (jsdom).
|
|
133
134
|
const stops = tabSequence(root, { frameworkPrefixes: prefixes, isVisible, isModal: options.isModal });
|
|
134
135
|
for (const jump of visualOrderJumps(stops)) {
|
|
135
136
|
const stop = stops[jump];
|
|
136
|
-
findings.push(make(stop.element, 'ngbr/tab-order-mismatch', 'moderate', `
|
|
137
|
-
`one that sits below or to
|
|
138
|
-
`
|
|
137
|
+
findings.push(make(stop.element, 'ngbr/tab-order-mismatch', 'moderate', `Tab order jumps backwards here: Tab reaches this control (stop ${stop.order}) after ` +
|
|
138
|
+
`one that sits below it or to its right, so focus moves against the reading order. ` +
|
|
139
|
+
`Heuristic — check the order makes sense to a sighted keyboard user.`, `${RULE_DOCS}/tab-order-mismatch`));
|
|
139
140
|
}
|
|
140
141
|
return findings;
|
|
141
142
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ngbracket/a11y-devtools",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Dev-only in-app accessibility auditing for Angular that maps each axe violation back to the component that rendered it — the attribution React overlay tools can't do.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Duncan Faulkner",
|