Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): make the Infrastructure radios keyboard reachable

Yudhi Armyndharis4d7c30aa5bbe
diff --git a/dashboard/src/hidden-controls.test.ts b/dashboard/src/hidden-controls.test.ts
new file mode 100644
index 000000000..ca5627c03
--- /dev/null
+++ b/dashboard/src/hidden-controls.test.ts
@@ -0,0 +1,36 @@
+import { test } from 'node:test';
+import assert from 'node:assert/strict';
+import { readFileSync } from 'node:fs';
+import { fileURLToPath } from 'node:url';
+import { dirname, join } from 'node:path';
+
+// A radio or checkbox that is drawn as something else (a card, a switch) still has to take keyboard
+// focus and show where it is. `display: none` removes the input from the tab order and from the
+// accessibility tree; hiding it with zero opacity keeps it focusable, but then the visible stand-in
+// has to carry the focus ring.
+
+const SRC = dirname(fileURLToPath(import.meta.url));
+
+interface Rule {
+ selectors: string[];
+ body: string;
+}
+
+// Flat style rules; a rule inside an @media block is listed like any other.
+function rules(file: string): Rule[] {
+ const css = readFileSync(join(SRC, file), 'utf8').replace(/\/\*[\s\S]*?\*\//g, '');
+ return [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].map(m => ({
+ selectors: m[1].split(',').map(s => s.trim()),
+ body: m[2],
+ }));
+}
+
+test('the Infrastructure radio inputs stay focusable and the card shows the focus ring', () => {
+ const all = rules('pages/Infrastructure.css');
+ const inputs = all.filter(r => r.selectors.some(s => /\.radio-option input$/.test(s)));
+ assert.ok(inputs.length > 0, 'no rule styles the radio inputs');
+ for (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\)/);
+});
diff --git a/dashboard/src/pages/Infrastructure.css b/dashboard/src/pages/Infrastructure.css
index 95d8db393..f7279e782 100644
--- a/dashboard/src/pages/Infrastructure.css
+++ b/dashboard/src/pages/Infrastructure.css
@@ -103,8 +103,19 @@
background: rgba(37, 211, 102, 0.05);
}
+/* Hidden but focusable: display: none would take the radio out of the tab order, and the arrow keys
+ that change the choice with it. */
.infrastructure-page .radio-option input {
- display: none;
+ position: absolute;
+ opacity: 0;
+ width: 1px;
+ height: 1px;
+ pointer-events: none;
+}
+
+.infrastructure-page .radio-option:has(input:focus-visible) {
+ outline: 2px solid var(--primary);
+ outline-offset: 2px;
}
.infrastructure-page .radio-option span {