tab-trail 1.0.0 → 1.1.0

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
@@ -2,6 +2,19 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 1.1.0 (2026-11-23)
6
+
7
+ 5 new checks and 2 new settings: focus you can see, skip links, popups with a way out, names, Tab cost, Region map.
8
+
9
+ - New check: No focus style (2.4.7 AA), a stop that shows nothing when Tab is on it.
10
+ - New check: Ghost stop (2.4.7 AA, 4.1.2 A), a stop that is off screen, invisible or inside aria-hidden.
11
+ - New check: Broken skip link (2.4.1 A), a skip link that goes nowhere, or many stops and no skip link.
12
+ - New check: No way out (2.1.2 A), a popup that Tab loops through with nothing that closes it.
13
+ - New check: Nameless stop (4.1.2 A), a stop with no name for screen readers. Hover a dot to see its name.
14
+ - New setting: Tab cost, the Tab presses to reach the main content and the page's goals, with Pick a goal.
15
+ - New setting: Region map, the stops per region as 1 bar.
16
+ - Copy for AI, problems() and window.__tabTrail gained the new checks, state().untested, cost() and regions().
17
+
5
18
  ## 1.0.0 (2026-10-29)
6
19
 
7
20
  First public release: every Tab stop in order, 7 checks in red with their WCAG rule, Play, Copy for AI and window.__tabTrail for tests.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <p align="center"><img src=".github/assets/trail.gif" width="960" alt="Tab trail on a small shop page: numbered dots and lines show the path of the Tab key, the orange ring moves with each Tab press, and 2 things Tab never reaches, an Add to cart button and a Send link, are marked in red. The panel on the right counts 7 stops, 2 missed spots and 1 hover-only menu."></p>
1
+ <p align="center"><img src=".github/assets/trail.gif" width="960" alt="Tab trail running on its own page, matjazkorosec.com/tools/tab-trail. The panel opens and counts 20 stops for the Tab key, 2 spots that look clickable but Tab skips (Add to cart, Send) and 1 menu that opens only on mouse hover. Then the orange ring follows 5 Tab presses along numbered dots joined by lines."></p>
2
2
 
3
3
  # Tab trail
4
4
 
@@ -25,11 +25,11 @@ Your bookmark keeps the version you dragged. To get new checks, delete it and dr
25
25
  ### Console
26
26
 
27
27
  <!-- console:start -->
28
- Copy [`dist/tab-trail.js`](https://raw.githubusercontent.com/matjazkorosec/tab-trail/v1.0.0/dist/tab-trail.js). On your site press F12, or Cmd+Option+I on a Mac (Cmd+Option+C in Safari), open Console and paste. If it asks, type allow pasting, press Enter, and paste again.
28
+ Copy [`dist/tab-trail.js`](https://raw.githubusercontent.com/matjazkorosec/tab-trail/v1.1.0/dist/tab-trail.js). On your site press F12, or Cmd+Option+I on a Mac (Cmd+Option+C in Safari), open Console and paste. If it asks, type allow pasting, press Enter, and paste again.
29
29
  <!-- console:end -->
30
30
 
31
31
  <!-- firefox:start -->
32
- Firefox can't store a bookmark longer than 65,536 characters, and the Tab trail bookmark is 223,286. In Firefox, paste the script in the console instead.
32
+ Firefox can't store a bookmark longer than 65,536 characters, and the Tab trail bookmark is 272,743. In Firefox, paste the script in the console instead.
33
33
  <!-- firefox:end -->
34
34
 
35
35
  ### Playwright
@@ -43,13 +43,18 @@ The script is in `node_modules/tab-trail/dist/tab-trail.js`. The example below r
43
43
  ## What it lists in red
44
44
 
45
45
  <!-- checks:start -->
46
- 1. **Missed spots** (WCAG 2.1.1 A): A red box marks something that looks clickable, like a box with a pointer cursor, a button role or a click handler in the HTML. The keyboard never gets there. [See it](https://matjazkorosec.com/tools/tab-trail#show-missed-spots)
47
- 2. **Hover menus** (WCAG 2.1.1 A, 2.4.7 AA): A menu that opens on mouse hover but never when Tab reaches it hides its links from keyboard users. Tab trail reads the page's CSS and marks each one with a red box. [See it](https://matjazkorosec.com/tools/tab-trail#show-hover-menus)
48
- 3. **Forced order** (WCAG 2.4.3 A): An element with tabindex="5" gets Tab before the rest of the page, wherever it sits. When that changes the order, it is listed in red: set it to 0 and move the element in the HTML instead. If it was first anyway, the Log only notes it. [See it](https://matjazkorosec.com/tools/tab-trail#show-forced-order)
49
- 4. **Hidden focus** (WCAG 2.4.11 AA): When Tab lands on something a sticky header, a cookie bar or a chat button covers completely, the panel lists it in red. Click it to scroll it into view. Fix it and Tab there again: it leaves the list. This check is new in WCAG 2.2 AA. [See it](https://matjazkorosec.com/tools/tab-trail#show-hidden-focus)
50
- 5. **Keyboard trap** (WCAG 2.1.2 A): When Tab and Shift+Tab both leave focus on the same spot, a keyboard user can't get out. The panel lists that stop in red, once, like "2: Message". A spot that keeps Tab but says how to leave, like a code editor, is not red. [See it](https://matjazkorosec.com/tools/tab-trail#show-keyboard-trap)
51
- 6. **Lost focus** (WCAG 2.4.3 A): When a popup or cookie bar closes, focus should go back to the button that opened it. If it drops to the top of the page instead, the panel lists it in red, like "2 → Start". [See it](https://matjazkorosec.com/tools/tab-trail#show-lost-focus)
52
- 7. **Out of order** (WCAG 2.4.3 A): Each time Tab jumps out of order, the panel lists the jump in red. A popup that blocks the page must get Tab first, or it is flagged too. [See it](https://matjazkorosec.com/tools/tab-trail#show-out-of-order)
46
+ - **03 Missed spots** (WCAG 2.1.1 A): A red box marks something that looks clickable, like a box with a pointer cursor, a button role or a click handler in the HTML. The keyboard never gets there. [See it](https://matjazkorosec.com/tools/tab-trail#show-missed-spots)
47
+ - **04 Hover menus** (WCAG 2.1.1 A, 2.4.7 AA): A menu that opens on mouse hover but never when Tab reaches it hides its links from keyboard users. Tab trail reads the page's CSS and marks each one with a red box. [See it](https://matjazkorosec.com/tools/tab-trail#show-hover-menus)
48
+ - **05 Forced order** (WCAG 2.4.3 A): An element with tabindex="5" gets Tab before the rest of the page, wherever it sits. When that changes the order, it is listed in red: set it to 0 and move the element in the HTML instead. If it was first anyway, the Log only notes it. [See it](https://matjazkorosec.com/tools/tab-trail#show-forced-order)
49
+ - **06 Hidden focus** (WCAG 2.4.11 AA): When Tab lands on something a sticky header, a cookie bar or a chat button covers completely, the panel lists it in red. Click it to scroll it into view. Fix it and Tab there again: it leaves the list. This check is new in WCAG 2.2 AA. [See it](https://matjazkorosec.com/tools/tab-trail#show-hidden-focus)
50
+ - **07 Keyboard trap** (WCAG 2.1.2 A): When Tab and Shift+Tab both leave focus on the same spot, a keyboard user can't get out. The panel lists that stop in red, once, like "2: Message". A spot that keeps Tab but says how to leave, like a code editor, is not red. [See it](https://matjazkorosec.com/tools/tab-trail#show-keyboard-trap)
51
+ - **08 Lost focus** (WCAG 2.4.3 A): When a popup or cookie bar closes, focus should go back to the button that opened it. If it drops to the top of the page instead, the panel lists it in red, like "2 → Start". [See it](https://matjazkorosec.com/tools/tab-trail#show-lost-focus)
52
+ - **09 Out of order** (WCAG 2.4.3 A): Each time Tab jumps out of order, the panel lists the jump in red. A popup that blocks the page must get Tab first, or it is flagged too. [See it](https://matjazkorosec.com/tools/tab-trail#show-out-of-order)
53
+ - **10 No focus style** (WCAG 2.4.7 AA): Tab trail compares how a stop looks before and after it gets focus: its outline, shadow, border, colors, underline, its ::before and ::after, and its parent, sibling, label and first child, so a ring drawn around it counts. Nothing changed means keyboard users can't see where they are. Copy for AI names the CSS rule that removes the outline. [See it](https://matjazkorosec.com/tools/tab-trail#show-no-focus-style)
54
+ - **11 Ghost stop** (WCAG 2.4.7 AA, 4.1.2 A): Tab lands on something nobody can see: off screen, no size, transparent, or inside aria-hidden. Off-screen stops, like a closed phone menu, become 1 red strip at the edge they hide behind, with the range. A slide or menu that moves in on focus passes. [See it](https://matjazkorosec.com/tools/tab-trail#show-ghost-stop)
55
+ - **12 Broken skip link** (WCAG 2.4.1 A): A skip link among the first stops points at an id that is missing or hidden, so Enter does nothing. A red line runs to an X where the target should be. With no skip link and 15 or more stops before the main content, that is listed too. [See it](https://matjazkorosec.com/tools/tab-trail#show-broken-skip-link)
56
+ - **13 No way out** (WCAG 2.1.2 A): Tab goes round and round inside a popup, and none of its stops closes it. Tab trail never presses keys itself, so it judges your own Tab presses. A native dialog opened with showModal() is never red, because Escape closes it. [See it](https://matjazkorosec.com/tools/tab-trail#show-no-way-out)
57
+ - **14 Nameless stop** (WCAG 4.1.2 A): An icon button or image link with no text, no aria-label and no alt makes a screen reader say only "button" or "link". Hover any dot to see the name Tab trail found: "3 · button · no name". [See it](https://matjazkorosec.com/tools/tab-trail#show-nameless-stop)
53
58
  <!-- checks:end -->
54
59
 
55
60
  Each check in full: [docs/checks.md](docs/checks.md). Everything else it does: [docs/features.md](docs/features.md). Keys and how to read the trail: [docs/keys.md](docs/keys.md).
@@ -66,7 +71,9 @@ While Tab trail is open, the page has `window.__tabTrail`, so a test or an AI ag
66
71
  - `window.__tabTrail.report()`: The Copy for AI text.
67
72
  - `window.__tabTrail.log()`: Every Log line as data: time, result, check, wcag, text, fixed, selector, stop.
68
73
  - `window.__tabTrail.state()`: { walked, total, done, untested }. done is true once Play reached the end. untested names the checks that never ran, like Lost focus when no popup was opened, so a green test can tell a clean page from a check that was skipped.
69
- - `window.__tabTrail.version`: "1.0.0"
74
+ - `window.__tabTrail.cost(selector)`: With a CSS selector, the Tab presses from the top of the page to that element, or null if Tab never reaches it. Without one, the goals Tab cost finds: name, presses, how it was found, selector.
75
+ - `window.__tabTrail.regions()`: How many stops sit in each region: { header, nav, main, aside, footer, other }.
76
+ - `window.__tabTrail.version`: "1.1.0"
70
77
  - `window.__tabTrail.close()`: Closes it.
71
78
  <!-- api:end -->
72
79
 
@@ -80,7 +87,7 @@ It fails when a check finds a problem, and attaches the whole report.
80
87
  Save the script in your repo once, so every CI run uses the version you tested:
81
88
 
82
89
  ```sh
83
- curl -o tests/tab-trail.js https://raw.githubusercontent.com/matjazkorosec/tab-trail/v1.0.0/dist/tab-trail.js
90
+ curl -o tests/tab-trail.js https://raw.githubusercontent.com/matjazkorosec/tab-trail/v1.1.0/dist/tab-trail.js
84
91
  ```
85
92
 
86
93
  Then load it with `page.evaluate`, so a strict CSP or Trusted Types don't block it:
@@ -95,12 +102,14 @@ test("Tab reaches everything", async ({ page }) => {
95
102
  test.setTimeout(300_000);
96
103
  await page.goto("http://localhost:5173/");
97
104
  await page.evaluate(script);
105
+ await page.evaluate(() => window.__tabTrail.play({ ignore: [".third-party-widget"] }));
98
106
  const { total } = await page.evaluate(() => window.__tabTrail.state());
99
107
  for (let i = 0; i <= total; i++) await page.keyboard.press("Tab");
100
108
  for (let i = 0; i <= total; i++) await page.keyboard.press("Shift+Tab");
101
- const report = await page.evaluate(() => window.__tabTrail.play({ ignore: [".third-party-widget"] }));
109
+ const report = await page.evaluate(() => window.__tabTrail.report());
102
110
  await test.info().attach("tab-trail-report.txt", { body: report, contentType: "text/plain" });
103
- const { done } = await page.evaluate(() => window.__tabTrail.state());
111
+ const { done, untested } = await page.evaluate(() => window.__tabTrail.state());
112
+ console.log("Not tested:", untested.join(", ") || "none");
104
113
  const problems = await page.evaluate(() => window.__tabTrail.problems());
105
114
  expect(done).toBe(true);
106
115
  expect(problems.map((p) => `${p.check}: ${p.selector}`)).toEqual([]);
@@ -117,7 +126,7 @@ declare global {
117
126
  problems(): Problem[];
118
127
  report(): string;
119
128
  log(): Line[];
120
- state(): { walked: number; total: number; done: boolean };
129
+ state(): { walked: number; total: number; done: boolean; untested: string[] };
121
130
  close(): void;
122
131
  };
123
132
  }
@@ -125,7 +134,7 @@ declare global {
125
134
  ```
126
135
  <!-- test:end -->
127
136
 
128
- Already run axe in your tests? Keep it: axe reads the HTML, Tab trail walks the Tab key. Play moves focus itself, so it checks Missed spots, Hover menus, Forced order and Hidden focus. The Tab presses before it, once forward and once back through every stop, judge Out of order and Keyboard trap; Lost focus needs a popup opened and closed. Add the script once per page: running it again closes it. Play takes about half a second a stop, so 300_000 ms covers about 600 stops.
137
+ Already run axe in your tests? Keep it: axe reads the HTML, Tab trail walks the Tab key. Play moves focus itself, so it checks Missed spots, Hover menus, Forced order and Hidden focus. Then the test presses Tab once forward and once back through every stop, counted after Play so stops that appear late are in, to judge Out of order and Keyboard trap; Lost focus needs a popup opened and closed. Add the script once per page: running it again closes it. Play takes about half a second a stop, so 300_000 ms covers about 600 stops.
129
138
 
130
139
  ## What it does to your page
131
140
 
package/data/api.json CHANGED
@@ -19,6 +19,14 @@
19
19
  "call": "window.__tabTrail.state()",
20
20
  "gives": "{ walked, total, done, untested }. done is true once Play reached the end. untested names the checks that never ran, like Lost focus when no popup was opened, so a green test can tell a clean page from a check that was skipped."
21
21
  },
22
+ {
23
+ "call": "window.__tabTrail.cost(selector)",
24
+ "gives": "With a CSS selector, the Tab presses from the top of the page to that element, or null if Tab never reaches it. Without one, the goals Tab cost finds: name, presses, how it was found, selector."
25
+ },
26
+ {
27
+ "call": "window.__tabTrail.regions()",
28
+ "gives": "How many stops sit in each region: { header, nav, main, aside, footer, other }."
29
+ },
22
30
  {
23
31
  "call": "window.__tabTrail.version",
24
32
  "gives": "\"VERSION\""
@@ -67,6 +67,41 @@
67
67
  "short": "\"1 time Tab jumped out of order.\"",
68
68
  "long": "Each time Tab jumps out of order, the panel lists the jump in red. A popup that blocks the page must get Tab first, or it is flagged too."
69
69
  },
70
+ {
71
+ "group": "red",
72
+ "wcag": "2.4.7 AA",
73
+ "title": "No focus style",
74
+ "short": "\"2 stops show no focus when Tab is on them.\"",
75
+ "long": "Tab trail compares how a stop looks before and after it gets focus: its outline, shadow, border, colors, underline, its ::before and ::after, and its parent, sibling, label and first child, so a ring drawn around it counts. Nothing changed means keyboard users can't see where they are. Copy for AI names the CSS rule that removes the outline."
76
+ },
77
+ {
78
+ "group": "red",
79
+ "wcag": "2.4.7 AA, 4.1.2 A",
80
+ "title": "Ghost stop",
81
+ "short": "\"7 stops you can't see when Tab is on them.\"",
82
+ "long": "Tab lands on something nobody can see: off screen, no size, transparent, or inside aria-hidden. Off-screen stops, like a closed phone menu, become 1 red strip at the edge they hide behind, with the range. A slide or menu that moves in on focus passes."
83
+ },
84
+ {
85
+ "group": "red",
86
+ "wcag": "2.4.1 A",
87
+ "title": "Broken skip link",
88
+ "short": "\"1 skip link goes nowhere.\"",
89
+ "long": "A skip link among the first stops points at an id that is missing or hidden, so Enter does nothing. A red line runs to an X where the target should be. With no skip link and 15 or more stops before the main content, that is listed too."
90
+ },
91
+ {
92
+ "group": "red",
93
+ "wcag": "2.1.2 A",
94
+ "title": "No way out",
95
+ "short": "\"1 popup has no keyboard way out.\"",
96
+ "long": "Tab goes round and round inside a popup, and none of its stops closes it. Tab trail never presses keys itself, so it judges your own Tab presses. A native dialog opened with showModal() is never red, because Escape closes it."
97
+ },
98
+ {
99
+ "group": "red",
100
+ "wcag": "4.1.2 A",
101
+ "title": "Nameless stop",
102
+ "short": "\"3 stops have no name for screen readers.\"",
103
+ "long": "An icon button or image link with no text, no aria-label and no alt makes a screen reader say only \"button\" or \"link\". Hover any dot to see the name Tab trail found: \"3 · button · no name\"."
104
+ },
70
105
  {
71
106
  "group": "read",
72
107
  "title": "Tab order",
@@ -113,7 +148,7 @@
113
148
  "group": "work",
114
149
  "title": "Play it",
115
150
  "short": "No Tab key? Press Play, it walks every stop.",
116
- "long": "Play moves focus through every stop for you and checks each one, then 1 line sums up all 7 checks. It only moves focus, it never clicks."
151
+ "long": "Play moves focus through every stop for you and checks each one, then 1 line sums up all 12 checks. It only moves focus, it never clicks."
117
152
  },
118
153
  {
119
154
  "group": "work",
@@ -151,6 +186,18 @@
151
186
  "short": "Dim the page, light up where Tab is.",
152
187
  "long": "Open Settings and tick Spotlight: the page goes dark except what Tab is on, so you follow it the way a keyboard user does. A missing focus ring is easy to spot, even for someone watching."
153
188
  },
189
+ {
190
+ "group": "settings",
191
+ "title": "Tab cost",
192
+ "short": "How many Tab presses to the goal?",
193
+ "long": "Lists up to 3 goals with the Tab presses it takes to reach them: the main content, buttons like Add to cart or Subscribe, and anything marked data-tab-trail-goal=\"Name\". Pick a goal lets you click any stop to add it. Each goal gets an orange ring and its number on the page."
194
+ },
195
+ {
196
+ "group": "settings",
197
+ "title": "Region map",
198
+ "short": "Where do the Tab presses go?",
199
+ "long": "Counts the stops in the header, navigation, main content, sidebar and footer, as 1 bar. Click a part to tint that region on the page. It shows at a glance when the content is buried behind the menus."
200
+ },
154
201
  {
155
202
  "group": "settings",
156
203
  "title": "Show lines",
package/data/limits.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "A loop that Tab never leaves, but Shift+Tab does, shows as Out of order, not Keyboard trap.",
5
5
  "It doesn't compare Tab order with the order you see. If CSS moves things around, follow the numbers and check it yourself.",
6
6
  "Play moves focus in Tab order without pressing the key, so code that listens for the Tab key only runs when you press Tab.",
7
- "It doesn't check the focus ring's look or contrast (it only flags links that stay invisible while they have focus), or what a screen reader says. Use Spotlight to look for yourself, and VoiceOver or NVDA to listen. Pages inside frames and web components with closed shadow roots are skipped.",
7
+ "It checks that something changes when a stop gets focus, not how strong the change is (that is AAA), or what a screen reader says. Use Spotlight to look for yourself, and VoiceOver or NVDA to listen. Pages inside frames and web components with closed shadow roots are skipped.",
8
8
  "Style sheets loaded from other sites without CORS can't be read, so hover menus styled there are not checked.",
9
9
  "It's made for Chrome, Edge, Firefox and Safari on a desktop computer. On a Mac, turn on Tab for links first, and Firefox needs the console."
10
10
  ]