Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

fix: the mode notes box stays in the accessibility tree while empty, so the first note is announced, and its link is underlined

matind76bd041ff5d
diff --git a/assets/css/demo-page.css b/assets/css/demo-page.css
index 99c649ae..e72d6b5c 100644
--- a/assets/css/demo-page.css
+++ b/assets/css/demo-page.css
@@ -106,9 +106,12 @@ body.hb [hidden]{display:none!important}
right end of the Watch step's heading row (below), so the stage keeps its place on a laptop's first screen. The switch is a
.seg too, and the .seg rules come later in the file: the rules here that must win name .seg.hb-modes. */
.hb-page .seg.hb-modes{gap:6px}
-.hb-mode-notes:not(:has(> p:not([hidden]))){display:none}
+/* The empty box is the live region that makes a screen reader read each note out loud, so it stays on the page: display:none would
+ take it out of the accessibility tree, and the first note might not be announced. It is hidden to the eye and taken out of the
+ flow instead, so it takes no room and adds no gap. */
+.hb-mode-notes:not(:has(> p:not([hidden]))){position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.hb-mode-notes p{margin:0;max-width:72ch;font:400 15px/1.55 var(--hb-font);color:var(--hb-dim)}
-.hb-mode-notes a{color:var(--hb-ink);text-underline-offset:3px}
+.hb-mode-notes a{color:var(--hb-ink);text-decoration:underline;text-underline-offset:3px}
/* Switches: a checkbox drawn as a track and knob (gradients, so no pseudo-elements on the input) */
.hb-switch{appearance:none;-webkit-appearance:none;flex:none;width:32px;height:20px;margin:0;border-radius:999px;cursor:pointer;
diff --git a/tests/pages.test.js b/tests/pages.test.js
index 2598da98..c09ede0a 100644
--- a/tests/pages.test.js
+++ b/tests/pages.test.js
@@ -535,8 +535,16 @@ test('the shared stylesheet draws the mode switch beside the Watch heading from
const has = sel => rules.some(r => r.selector.split(',').map(s => s.trim()).includes(sel));
for (const sel of ['.hb-page .seg.hb-modes', '.hb-mode-notes p', '.hb-lesson', '.hb-lesson a', '.hb-lesson-nav', '.hb-lesson-prev',
'.hb-lesson-next', '.hb-lesson-all', '.hb-why p', '.hb-seen']) assert.ok(has(sel), sel);
- assert.ok(rules.some(r => r.selector === '.hb-mode-notes:not(:has(> p:not([hidden])))' && /display:none/.test(r.body)),
- 'an empty notes box takes no room');
+ // The empty box is the aria-live region that makes a screen reader read each note out, so it must stay rendered: display:none
+ // would take it out of the accessibility tree, and the first note shown might not be announced. It is hidden to the eye and taken
+ // out of the flow instead, which takes no room and adds no gap.
+ const emptyNotes = rules.filter(r => r.selector === '.hb-mode-notes:not(:has(> p:not([hidden])))');
+ assert.ok(emptyNotes.some(r => /(^|;)\s*position:\s*absolute\s*(;|$)/.test(r.body) && /(^|;)\s*clip-path:\s*inset\(50%\)\s*(;|$)/.test(r.body)),
+ 'an empty notes box takes no room: it is taken out of the flow and clipped away');
+ assert.ok(!emptyNotes.some(r => /(^|;)\s*display:\s*none\s*(;|$)/.test(r.body)),
+ 'an empty notes box stays rendered, so the first note shown is announced by the live region');
+ assert.ok(rules.some(r => r.selector === '.hb-mode-notes a' && /(^|;)\s*text-decoration:\s*underline\s*(;|$)/.test(r.body)),
+ 'a link in a note is underlined');
// The switch is also a .seg, and the .seg rules (the gap, and the phone rule for .seg buttons) come later in the file: the
// switch's own rules name .seg.hb-modes so that they outrank them and the three buttons are equal on phones.
assert.ok(rules.some(r => r.selector === '.hb-page .seg.hb-modes button' && /(^|;)\s*flex:\s*1 1 0\s*(;|$)/.test(r.body)),