Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): draw the focus ring in a darker token
Yudhi Armyndharis819175ecb6fc
diff --git a/dashboard/src/App.css b/dashboard/src/App.cssindex 1b798ec95..4738949f3 100644--- a/dashboard/src/App.css+++ b/dashboard/src/App.css@@ -6,6 +6,11 @@--bg-light, and 4.82:1 on --primary-soft (4.63:1 over --bg-light), the tint the active sidebar itemuses. On the heaviest green tint a badge paints (18 percent over white) it measures 4.61:1. */--primary-text: #167c3b;+ /* The keyboard focus ring. WCAG 2.2 SC 1.4.11 asks 3:1 of a focus indicator; the brand fill measures 1.98:1 on white+ and 1.74:1 on --primary-soft over --bg-light. --primary-text clears it on every surface a ring is drawn on: 5.28:1+ on white, 5.04:1 on --bg-light and 4.63:1 on --primary-soft over --bg-light. In the dark theme it is the brand+ green itself, 7.38:1 on --bg-white and 5.15:1 on --primary-soft over it. */+ --focus-ring: var(--primary-text);--primary-hover: #1da851;--primary-soft: rgba(37, 211, 102, 0.12);--bg-light: #f8fafc;diff --git a/dashboard/src/components/CustomSelect.css b/dashboard/src/components/CustomSelect.cssindex 0e330eab3..fad6768c3 100644--- a/dashboard/src/components/CustomSelect.css+++ b/dashboard/src/components/CustomSelect.css@@ -26,7 +26,7 @@}.custom-select-trigger:focus-visible {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;}diff --git a/dashboard/src/components/GlobalSearch.css b/dashboard/src/components/GlobalSearch.cssindex 626fd690d..2b4f94868 100644--- a/dashboard/src/components/GlobalSearch.css+++ b/dashboard/src/components/GlobalSearch.css@@ -80,7 +80,7 @@.global-search-hit:focus-visible {background: var(--primary-soft);- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: -2px;}diff --git a/dashboard/src/focus-ring.test.ts b/dashboard/src/focus-ring.test.tsindex cc3347ae0..eb5405c6a 100644--- a/dashboard/src/focus-ring.test.ts+++ b/dashboard/src/focus-ring.test.ts@@ -52,10 +52,28 @@ test('chat menu entries and search hits draw a ring on keyboard focus', () => {]) {const rule = all.find(r => r.selectors.includes(selector));assert.ok(rule, `no rule for ${selector}`);- assert.match(rule.body, /outline:\s*2px solid var\(--primary\)/, selector);+ assert.match(rule.body, /outline:\s*2px solid var\(--focus-ring\)/, selector);}});+// The brand fill (#25d366) is 1.98:1 on white, under the 3:1 WCAG 2.2 SC 1.4.11 asks of a focus indicator. Every ring+// is drawn in the --focus-ring token (App.css, where its contrast is checked), so one value moves them all.+test('every keyboard focus ring is drawn in the --focus-ring token', () => {+ const drawn = all.flatMap(r =>+ [...r.body.matchAll(/(?:^|;)\s*outline(?:-color)?\s*:\s*([^;]+)/g)]+ .map(m => ({ at: `${r.file}: ${r.selectors.join(', ')}`, value: m[1].trim() }))+ .filter(({ value }) => !/^(?:none|0)$/.test(value)),+ );+ assert.ok(+ drawn.some(({ at }) => at.startsWith('index.css')),+ 'the global ring is not seen',+ );+ assert.deepEqual(+ drawn.filter(({ value }) => !/\bvar\(--focus-ring\)/.test(value)).map(({ at, value }) => `${at} => ${value}`),+ [],+ );+});+// The soft brand fill a focused hit paints is a tint: the muted meta line (the chat id and the time) measures 4.35:1// on it in the light theme and 3.98:1 in the dark one, where the plain hover fill it replaced gave 4.55:1 and 6.96:1.test('the meta line of a keyboard-focused search hit takes the secondary text colour', () => {diff --git a/dashboard/src/hidden-controls.test.ts b/dashboard/src/hidden-controls.test.tsindex 18309478c..c92c79596 100644--- a/dashboard/src/hidden-controls.test.ts+++ b/dashboard/src/hidden-controls.test.ts@@ -32,7 +32,7 @@ test('the Infrastructure radio inputs stay focusable and the card shows the focufor (const r of inputs) assert.doesNotMatch(r.body, /display:\s*none/, `${r.selectors.join(', ')} removes the radio`);const ring = all.find(r => r.selectors.some(s => /\.radio-option:has\(input:focus-visible\)$/.test(s)));assert.ok(ring, 'no focus ring for the focused radio card');- assert.match(ring.body, /outline:\s*2px solid var\(--primary\)/);+ assert.match(ring.body, /outline:\s*2px solid var\(--focus-ring\)/);});/** Every stylesheet under src/, as a path relative to src/. */@@ -54,7 +54,7 @@ test('every stylesheet that hides a toggle checkbox rings its slider on keyboardconst ring = rules(file).find(r =>r.selectors.some(s => /\.toggle-switch input:focus-visible \+ \.toggle-slider$/.test(s)),);- return !ring || !/outline:\s*2px solid var\(--primary\)/.test(ring.body);+ return !ring || !/outline:\s*2px solid var\(--focus-ring\)/.test(ring.body);});assert.deepEqual(missing, []);});diff --git a/dashboard/src/index.css b/dashboard/src/index.cssindex 9b3bbcab9..170936139 100644--- a/dashboard/src/index.css+++ b/dashboard/src/index.css@@ -80,11 +80,11 @@ button {transition: border-color 0.25s;}/* Visible keyboard focus — cross-browser and keyboard-only, so the ring guides Tab navigation- without flashing on every mouse click. */+ without flashing on every mouse click. Every ring is drawn in --focus-ring (App.css, which has the contrast). */button:focus-visible,a:focus-visible,[tabindex]:focus-visible {- outline: 2px solid var(--primary, #25d366);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;}button:focus:not(:focus-visible) {diff --git a/dashboard/src/pages/Chats.css b/dashboard/src/pages/Chats.cssindex f2b52471c..43581d550 100644--- a/dashboard/src/pages/Chats.css+++ b/dashboard/src/pages/Chats.css@@ -1288,7 +1288,7 @@/* A bubble is a keyboard stop (ChatThread): the ring says which message the arrow keys act on. */.chats-page .message-bubble-container:focus-visible {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;border-radius: 12px;}@@ -1915,7 +1915,7 @@}.chats-page .icon-btn:focus-visible {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;}@@ -2067,7 +2067,7 @@}.chats-page .chat-row-menu-trigger:focus-visible {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 1px;}@@ -2140,7 +2140,7 @@.chats-page .chat-row-menu-popover button:focus-visible,.chats-page .room-menu-popover button:focus-visible {background: var(--primary-soft);- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: -2px;}@@ -2225,7 +2225,7 @@}.chats-page .search-clear:focus-visible {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 1px;}diff --git a/dashboard/src/pages/Infrastructure.css b/dashboard/src/pages/Infrastructure.cssindex 4847113b9..492fdec97 100644--- a/dashboard/src/pages/Infrastructure.css+++ b/dashboard/src/pages/Infrastructure.css@@ -114,7 +114,7 @@}.infrastructure-page .radio-option:has(input:focus-visible) {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;}@@ -280,7 +280,7 @@}.infrastructure-page .toggle-switch input:focus-visible + .toggle-slider {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;}diff --git a/dashboard/src/pages/Plugins.css b/dashboard/src/pages/Plugins.cssindex d9d7a7248..71f53176a 100644--- a/dashboard/src/pages/Plugins.css+++ b/dashboard/src/pages/Plugins.css@@ -573,7 +573,7 @@}.plugins-page .toggle-switch input:focus-visible + .toggle-slider {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;}diff --git a/dashboard/src/pages/Sessions.css b/dashboard/src/pages/Sessions.cssindex 7a66455cf..53dcc7b72 100644--- a/dashboard/src/pages/Sessions.css+++ b/dashboard/src/pages/Sessions.css@@ -896,7 +896,7 @@}.sessions-page .toggle-switch input:focus-visible + .toggle-slider {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;}diff --git a/dashboard/src/pages/Webhooks.css b/dashboard/src/pages/Webhooks.cssindex 1c11638f6..f8ad27e11 100644--- a/dashboard/src/pages/Webhooks.css+++ b/dashboard/src/pages/Webhooks.css@@ -666,7 +666,7 @@}.webhooks-page .toggle-switch input:focus-visible + .toggle-slider {- outline: 2px solid var(--primary);+ outline: 2px solid var(--focus-ring);outline-offset: 2px;}diff --git a/dashboard/src/pages/Webhooks.css.test.ts b/dashboard/src/pages/Webhooks.css.test.tsindex 867947d09..ddd77ff2d 100644--- a/dashboard/src/pages/Webhooks.css.test.ts+++ b/dashboard/src/pages/Webhooks.css.test.ts@@ -12,5 +12,5 @@ const css = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'Webhookstest('the hidden toggle checkbox shows keyboard focus on its slider', () => {const rule = /\.webhooks-page \.toggle-switch input:focus-visible \+ \.toggle-slider\s*\{([^}]*)\}/.exec(css);assert.ok(rule, 'no focus-visible style for the toggle slider');- assert.match(rule[1], /outline:\s*2px solid var\(--primary\)/);+ assert.match(rule[1], /outline:\s*2px solid var\(--focus-ring\)/);});diff --git a/dashboard/src/theme-contrast.test.ts b/dashboard/src/theme-contrast.test.tsindex 849426615..7059e1d15 100644--- a/dashboard/src/theme-contrast.test.ts+++ b/dashboard/src/theme-contrast.test.ts@@ -186,6 +186,31 @@ test('every status text twin clears 4.5:1 on the translucent fill its own rule passert.deepEqual(offenders, []);});+// WCAG 2.2 SC 1.4.11 asks 3:1 of a keyboard focus indicator against what it is drawn on: the page and card surfaces+// and the soft brand tint of a focused menu entry or search hit. The brand fill measured 1.98:1 on white.+test('the focus ring clears 3:1 on every surface it is drawn on, in both themes', () => {+ assert.match(CSS, /--focus-ring:\s*var\(--primary-text\)/);+ for (const [anchor, tint] of [+ [LIGHT, 0.12],+ [DARK, 0.18],+ [DARK_MEDIA, 0.18],+ ] as const) {+ const block = blockAfter(anchor);+ const ring = rgb(hexOf(block, '--primary-text'));+ for (const surface of ['--bg-white', '--bg-light']) {+ const bg = rgb(hexOf(block, surface));+ const soft = mix(rgb(hexOf(blockAfter(LIGHT), '--primary')), tint, bg);+ for (const [name, fill] of [+ ['the surface', bg],+ ['the soft tint over it', soft],+ ] as const) {+ const ratio = contrast(ring, fill);+ assert.ok(ratio >= 3, `${anchor} ring on ${name} of ${surface} is ${ratio.toFixed(2)}:1`);+ }+ }+ }+});+test('the search match and the Number Checker highlight pill clear AA in both themes', () => {const search = readFileSync(join(dirname(fileURLToPath(import.meta.url)), 'components/GlobalSearch.css'), 'utf8');const mark =