Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): show keyboard focus on switch toggles

Yudhi Armyndharis449e76d7d310
diff --git a/dashboard/src/hidden-controls.test.ts b/dashboard/src/hidden-controls.test.ts
index ca5627c03..18309478c 100644
--- a/dashboard/src/hidden-controls.test.ts
+++ b/dashboard/src/hidden-controls.test.ts
@@ -1,6 +1,6 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
-import { readFileSync } from 'node:fs';
+import { readFileSync, readdirSync } from 'node:fs';
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
@@ -34,3 +34,27 @@ test('the Infrastructure radio inputs stay focusable and the card shows the focu
assert.ok(ring, 'no focus ring for the focused radio card');
assert.match(ring.body, /outline:\s*2px solid var\(--primary\)/);
});
+
+/** Every stylesheet under src/, as a path relative to src/. */
+function cssFiles(dir = SRC): string[] {
+ return readdirSync(dir, { withFileTypes: true }).flatMap(entry => {
+ const full = join(dir, entry.name);
+ if (entry.isDirectory()) return cssFiles(full);
+ return entry.name.endsWith('.css') ? [full.slice(SRC.length + 1)] : [];
+ });
+}
+
+test('every stylesheet that hides a toggle checkbox rings its slider on keyboard focus', () => {
+ const hiding = cssFiles().filter(file =>
+ rules(file).some(r => r.selectors.some(s => /\.toggle-switch input$/.test(s))),
+ );
+ // Vacuity floor: Sessions, Webhooks, Infrastructure and Plugins each carry their own copy.
+ assert.ok(hiding.length >= 4, `only ${hiding.length} stylesheets hide a toggle checkbox`);
+ const missing = hiding.filter(file => {
+ const 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);
+ });
+ assert.deepEqual(missing, []);
+});
diff --git a/dashboard/src/pages/Infrastructure.css b/dashboard/src/pages/Infrastructure.css
index f7279e782..ee9cf6d61 100644
--- a/dashboard/src/pages/Infrastructure.css
+++ b/dashboard/src/pages/Infrastructure.css
@@ -281,6 +281,11 @@
transform: translateX(22px);
}
+.infrastructure-page .toggle-switch input:focus-visible + .toggle-slider {
+ outline: 2px solid var(--primary);
+ outline-offset: 2px;
+}
+
/* Queue Stats */
.infrastructure-page .queue-stats {
margin-top: 1.5rem;
diff --git a/dashboard/src/pages/Plugins.css b/dashboard/src/pages/Plugins.css
index 8a4e96a81..06b06141c 100644
--- a/dashboard/src/pages/Plugins.css
+++ b/dashboard/src/pages/Plugins.css
@@ -570,6 +570,11 @@
transform: translateX(22px);
}
+.plugins-page .toggle-switch input:focus-visible + .toggle-slider {
+ outline: 2px solid var(--primary);
+ outline-offset: 2px;
+}
+
.plugins-page .no-config {
text-align: center;
padding: 2rem;