Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: restore visible keyboard focus ring on form fields (#7524)

[._.]/ Adam Eivy2b3b4d719e23
diff --git a/client/src/index.css b/client/src/index.css
index e1f91e5bd2..fea88670f3 100644
--- a/client/src/index.css
+++ b/client/src/index.css
@@ -1691,16 +1691,22 @@ html[data-port-theme="kestrel-neon"] body {
outline-offset: 2px;
}
-/* Soften focus on text-entry fields — the bright 2px ring at offset 2 reads
- as a thick blue border around prose textareas, which is harsh when you're
- reading a long draft. Form fields already have a visible cursor + the
- field's own border, so a 1px low-alpha indicator flush against the border
- is enough. Buttons/links keep the strong indicator below for keyboard
- navigation. */
-:is(input, textarea, select, [contenteditable="true"], [contenteditable=""]):focus-visible {
- outline: 1px solid rgb(var(--port-focus-ring) / 0.35);
- outline-offset: 0;
-}
+/* Form fields (input/textarea/select/contenteditable) get the SAME solid,
+ opaque `*:focus-visible` ring as everything else — no dimmer variant.
+ A prior rule here dropped them to a 1px outline at 35% alpha to avoid a
+ "harsh" ring on prose textareas (Writers Room), but `:focus-visible`
+ fires on both keyboard AND pointer focus for text-entry elements (a
+ browser heuristic distinct from buttons/links, where a mouse click never
+ matches it), so the low-alpha ring was also the ONLY keyboard indicator a
+ field ever got — and at 35% alpha composited over a themed input
+ background it fell to ~1.7-1.8:1, well under the 3:1 WCAG non-text
+ contrast floor (#7524). `--port-focus-ring` at full opacity already
+ clears >=3:1 against every theme's page/card/input surface (see
+ portosThemes.test.js), so removing the exception fixes contrast without
+ a per-theme token change. Distinguishing "soft on click, strong on Tab"
+ for text fields would need JS-based input-modality tracking (no keyboard
+ click/keyboard split exists in CSS for this element class) — out of
+ scope for this fix; theme focus glows below remain as decoration. */
/* Accessibility: Remove focus outline for mouse users while keeping it for keyboard */
*:focus:not(:focus-visible) {
diff --git a/client/src/themes/portosThemes.test.js b/client/src/themes/portosThemes.test.js
index e75b8ff6c8..531be1157a 100644
--- a/client/src/themes/portosThemes.test.js
+++ b/client/src/themes/portosThemes.test.js
@@ -25,6 +25,10 @@ const contrastRatio = (a, b) => {
const AA_SMALL_TEXT = 4.5;
const MAX_COMFORTABLE_TEXT_CONTRAST = 15.5;
+// WCAG 2.x 1.4.11 non-text contrast floor for UI components / focus
+// indicators — lower than the 4.5:1 text floor above on purpose; a focus
+// ring only needs to be locatable, not read as prose.
+const NON_TEXT_CONTRAST = 3;
const REQUIRED_COLOR_TOKENS = [
'--port-bg',
@@ -86,6 +90,23 @@ const minimumCardSurface = (theme) => {
return card.map((channel, index) => floor * channel + (1 - floor) * bg[index]);
};
+// `--port-input-bg` is a raw CSS color (not a bare "R G B" token like the
+// others), either a same-value reference to the page background or a literal
+// `rgb(r g b [/ alpha])`. Composite it over the page the way a real <input>
+// renders, so the contrast check below matches what a user actually sees
+// under the field, not the token's own (possibly translucent) color alone.
+const inputSurface = (theme) => {
+ const page = parseRgb(theme.colors['--port-bg']);
+ const raw = theme.tokens['--port-input-bg'];
+ if (raw.includes('var(--port-bg)')) return page;
+ const match = raw.match(/rgb\(\s*(\d+)\s+(\d+)\s+(\d+)\s*(?:\/\s*([\d.]+))?\s*\)/);
+ expect(match, `--port-input-bg not parseable: ${raw}`).toBeTruthy();
+ const [, r, g, b, alphaText] = match;
+ const rgb = [r, g, b].map(Number);
+ const alpha = alphaText === undefined ? 1 : Number(alphaText);
+ return rgb.map((channel, index) => alpha * channel + (1 - alpha) * page[index]);
+};
+
describe('portosThemes warning token contrast', () => {
const entries = Object.values(THEMES);
@@ -297,6 +318,47 @@ describe('the theme-scoped focus glow only matches themes that declare it', () =
);
});
+// #7524: a `:focus-visible` exception dropped the keyboard indicator on
+// input/textarea/select/contenteditable to a 1px outline at 35% alpha —
+// composited over a themed field background that measured ~1.7-1.8:1,
+// well under the 3:1 WCAG non-text contrast floor, so keyboard users lost
+// their ONLY focus cue on every form field in every theme (text fields fire
+// `:focus-visible` on pointer focus too, so the low-alpha ring was not a
+// mouse-only fallback with a stronger keyboard variant elsewhere — it was
+// the whole indicator). Fixed by removing the exception so form fields fall
+// through to the same solid, opaque `*:focus-visible` ring as everything
+// else. These tests would have failed against the pre-fix CSS and guard
+// both the specific regression (the low-alpha carve-out returning) and the
+// general contract (a future theme shipping a --port-focus-ring too weak to
+// clear 3:1 once the CSS applies it to a real field).
+describe('keyboard focus indicator on form fields (#7524)', () => {
+ const entries = Object.values(THEMES);
+ const css = readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'index.css'), 'utf8');
+
+ it('does not reintroduce a translucent :focus-visible outline for form fields', () => {
+ expect(css).not.toMatch(
+ /:is\([^)]*\b(?:input|textarea|select|contenteditable)\b[^)]*\):focus-visible\s*{[^}]*outline:\s*1px solid rgb\(var\(--port-focus-ring\)\s*\/\s*0\.\d+\)/,
+ );
+ });
+
+ it.each(entries.map((theme) => [theme.id, theme]))(
+ '%s: --port-focus-ring clears the 3:1 non-text floor against page, card, and input surfaces',
+ (_id, theme) => {
+ const ring = parseRgb(theme.colors['--port-focus-ring']);
+ const surfaces = {
+ page: parseRgb(theme.colors['--port-bg']),
+ card: parseRgb(theme.colors['--port-card']),
+ minCard: minimumCardSurface(theme),
+ input: inputSurface(theme),
+ };
+ for (const [label, surface] of Object.entries(surfaces)) {
+ const ratio = contrastRatio(ring, surface);
+ expect(ratio, `--port-focus-ring vs ${label} in ${theme.id}`).toBeGreaterThanOrEqual(NON_TEXT_CONTRAST);
+ }
+ },
+ );
+});
+
describe('DEFAULT_AVATAR_COLOR', () => {
it('is a literal #rrggbb hex — a native <input type="color"> rejects anything else', () => {
expect(DEFAULT_AVATAR_COLOR).toMatch(/^#[0-9a-f]{6}$/);