Skip to content

bug(platform): credential and member row-menu dialogs drop keyboard focus to the page body #3715

Closed

Description

@yannickmonney

P3 · WCAG 2.1 SC 2.4.3 (Focus Order) · Reproduced locally at d351611bdd942ffeed758147ccaf57e70877125a (origin/main, 2026-09-28) with the keyboard in Chromium.

On Settings → Connectors and Settings → AI providers, every dialog opened from a credential row's actions menu drops keyboard focus to <body> when it closes. That covers Edit credential, Replace token / API key / username & password and Delete. The Settings → Members row menu (Edit) behaves the same way, through the same missing wiring. A keyboard or screen-reader user lands at the top of the document and has to tab back through the settings rail, the toolbar and every row to reach where they were.

Reproduction

  1. Tab to a credential row's actions button ("Actions for GitHub") and press Enter.
  2. Arrow to Edit credential (or Replace token, or Delete) and press Enter. The dialog opens and takes focus correctly.
  3. Press Escape (or activate Cancel).
  4. Check document.activeElement.

Expected: Focus returns to the row's "Actions for GitHub" button that opened the menu. That is the WAI-ARIA dialog pattern, and what Contacts' row menu, the Add credential button and the OAuth apps Configure/Remove buttons on the same page do.

Actual: document.activeElement is <body> for all three dialogs. The same happens on the AI providers table and on the Members table's Edit (frozen output below).

User impact

After every credential edit, secret rotation or cancelled delete, and after every member edit, keyboard users lose their place in the table and must re-navigate from the top of the page. On a long list this repeats for every row they work through.

Cause

  • The dialogs open from menu items that unmount with the menu, so the dialog primitive has nothing to return focus to unless it is given a ref.
  • @tale/ui's EntityRowActions exposes triggerRef (entity-row-actions.tsx:48), and the dialogs accept restoreFocusRef.
  • CredentialRowActions wires neither (credential-row-actions.tsx:193–245), and neither does member-row-actions.tsx.
  • Compare contact-row-actions.tsx:31, 82–106, which passes triggerRef={menuTriggerRef} and restoreFocusRef={menuTriggerRef} to each dialog.
  • Sweep hint, from source reading only and not exercised in this audit: team-row-actions.tsx, automation-row-actions.tsx and project-row-actions.tsx also pass no triggerRef.

Executable local proof and controls

probes/proof-focus.cjs and probes/proof-providers-shared.cjs (below) run against fresh synthetic organizations, keyboard only; p4-members-focus.cjs runs on the seeded dev org. Frozen output at d351611bd:

setup: fresh org aFc5gCEU3YCn9Tcct0A37sg1ypL0PkOY with one GitHub credential and one contact
credential row > Edit credential: {"item":"div \"Edit credential\"","focusWhileOpen":"input \"\"","focusAfterEscape":"BODY"}
CONFIRMED closing "Edit credential" (opened from the row menu) leaves focus on <body>
credential row > Replace token: {"item":"div \"Replace token\"","focusWhileOpen":"input \"\"","focusAfterEscape":"BODY"}
CONFIRMED closing "Replace token" (opened from the row menu) leaves focus on <body>
credential row > Delete: {"item":"div \"Delete\"","focusWhileOpen":"div \"Delete credential\"","focusAfterEscape":"BODY"}
CONFIRMED closing "Delete" (opened from the row menu) leaves focus on <body>
control: Add credential dialog closed with Escape -> focus button "Add credential"
control: contacts row > Edit: {"item":"div \"Edit\"","focusWhileOpen":"input \"\"","focusAfterEscape":"button \"Open menu\""}
CONTROL a row menu with restoreFocusRef returns focus to its trigger
--- AI providers (proof-providers-shared.cjs) ---
fixture env provider credential -> 200 {"credentialId":"434b93f3-9f13-4939-89d1-241f136eb838"}
AI providers row > Delete: {"item":"div \"Delete\"","focusAfterEscape":"BODY"}
CONFIRMED the AI providers table (same CredentialRowActions) loses focus the same way
--- Members (p4-members-focus.cjs, seeded dev org) ---
members row trigger: Open menu
members row > Edit: {"item":"div \"Edit\"","focusWhileOpen":"input \"\"","focusAfterEscape":"BODY"}

Controls (same run):

  • Contacts' row menu → Edit → Escape returns focus to its "Open menu" trigger.
  • The Add credential dialog returns focus to "Add credential".
  • In the exploration probe p4-oauthcard-focus.cjs, the OAuth apps card's Configure and Remove dialogs return focus to their buttons.

Mocked boundary

None. Real SPA, backend and PostgreSQL; keyboard only.

Local stack (loopback only): a detached worktree of d351611bd with bun install --frozen-lockfile; a fresh PostgreSQL 16.13 + pg_search 0.22.6 + pgvector 0.8.1 cluster bootstrapped like the tale-db image plus services/db/init-scripts; the backend from services/platform (node --experimental-transform-types --import ./backend/node-loader.mjs backend/main.ts, TALE_ROLE=all, PORT=3005, SITE_URL=http://localhost:3000, an empty TALE_CONFIG_DIR, TALE_CONFIG_BUILTIN_DIR=configs/platform/custom, TALE_DEV_SEED_USER=1, TALE_ALLOW_OPEN_SIGN_UP=true, locally generated ENCRYPTION_SECRET_HEX/BETTER_AUTH_SECRET); the SPA via TALE_BACKEND_URL=http://127.0.0.1:3005 bunx --bun vite --port 3000; Chromium 141 driven by the worktree's playwright-core 1.58.2. The backend ran with NODE_USE_ENV_PROXY=1 HTTPS_PROXY=HTTP_PROXY=http://127.0.0.1:9 NO_PROXY=127.0.0.1,localhost,::1, so every non-loopback fetch failed at a dead proxy: no real provider, mailbox or external service was reachable. Each proof mints its own synthetic organization through POST /api/auth/sign-up/email + POST /api/auth/organization/create.

Deduplication

probes/lib.cjs (shared helpers)
// Shared helpers for the TALE-78 local audit probes. Everything targets the local stack only:
// SPA http://localhost:3000 (proxying /api to the backend on :3005), fake vendor https://127.0.0.1:4443.
const { chromium } = require('/agent/.runtime/home/scratch/tale78/tale/node_modules/playwright-core');
const fs = require('node:fs');
const BASE = 'http://localhost:3000';
const ORIGIN = { origin: BASE };
const PW = 'TaleAudit!Passw0rd';
const USERS = {
  owner: { email: '[email protected]', password: 'TaleDev!Passw0rd' },
};
async function launch() {
  return chromium.launch({ executablePath: '/opt/ms-playwright/chromium-1194/chrome-linux/chrome', headless: true });
}
async function newContext(browser, opts = {}) {
  const context = await browser.newContext({ baseURL: BASE, ignoreHTTPSErrors: true, serviceWorkers: 'block', viewport: opts.viewport ?? { width: 1280, height: 900 }, locale: 'en-US' });
  return context;
}
async function signIn(context, who) {
  const u = typeof who === 'string' ? (USERS[who] ?? { email: who, password: PW }) : who;
  const r = await context.request.post('/api/auth/sign-in/email', { data: { email: u.email, password: u.password }, headers: ORIGIN });
  if (!r.ok()) throw new Error(`sign-in ${u.email} -> ${r.status()} ${await r.text()}`);
  return r.json();
}
async function api(context, method, path, data) {
  const r = await context.request.fetch(path, { method, data, headers: ORIGIN });
  let body = null;
  const text = await r.text();
  try { body = JSON.parse(text); } catch { body = text; }
  return { status: r.status(), body };
}
function watch(page, sink) {
  page.on('console', (m) => { if (['error', 'warning'].includes(m.type())) sink.push(`[console.${m.type()}] ${m.text().slice(0, 300)}`); });
  page.on('pageerror', (e) => sink.push(`[pageerror] ${String(e).slice(0, 300)}`));
  page.on('response', (r) => { if (r.status() >= 400 && r.url().includes('/api/')) sink.push(`[http ${r.status()}] ${r.request().method()} ${r.url().replace(BASE, '')}`); });
}
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
module.exports = { launch, newContext, signIn, api, watch, sleep, BASE, ORIGIN, PW, USERS, fs };

// ---- fresh synthetic organizations for self-contained proofs ------------------------------------
async function freshOrg(browser, label) {
  const stamp = `${label}-${Date.now().toString(36)}`;
  const email = `proof-${stamp}@tale.test`;
  const ctx = await newContext(browser);
  const su = await api(ctx, 'POST', '/api/auth/sign-up/email', { email, password: PW, name: `Proof ${label}` });
  if (su.status !== 200) throw new Error(`sign-up ${email}: ${su.status} ${JSON.stringify(su.body)}`);
  const org = await api(ctx, 'POST', '/api/auth/organization/create', { name: `Proof ${stamp}`, slug: `proof-${stamp}` });
  if (org.status !== 200) throw new Error(`org create: ${org.status} ${JSON.stringify(org.body)}`);
  await api(ctx, 'POST', '/api/auth/organization/set-active', { organizationId: org.body.id });
  return { ctx, orgId: org.body.id, email, stamp };
}
async function addMember(browser, owner, role) {
  const email = `proof-${owner.stamp}-${role}@tale.test`;
  const ctx = await newContext(browser);
  const su = await api(ctx, 'POST', '/api/auth/sign-up/email', { email, password: PW, name: `Proof ${role}` });
  const add = await api(owner.ctx, 'POST', `/api/app/members?orgId=${owner.orgId}`, { userId: su.body.user.id, role });
  if (add.status !== 200) throw new Error(`add member ${role}: ${add.status} ${JSON.stringify(add.body)}`);
  return { ctx, email, memberId: add.body.memberId };
}
const creds = async (ctx, orgId) => (await api(ctx, 'GET', `/api/app/connector-credentials?orgId=${orgId}`)).body.credentials;
const vendorControl = (q) => fetch(`https://127.0.0.1:4443/control?${q}`).then((r) => r.json());
const toasts = async (page) => (await page.locator('[role="region"] li').allInnerTexts()).map((s) => s.replace(/\s*\n+\s*/g, ' ').trim()).filter(Boolean);
const focusedDesc = (page) => page.evaluate(() => { const e = document.activeElement; if (!e || e === document.body) return 'BODY'; return `${e.tagName.toLowerCase()} "${(e.getAttribute('aria-label') || e.innerText || '').trim().split('\n')[0].slice(0, 50)}"`; });
Object.assign(module.exports, { freshOrg, addMember, creds, vendorControl, toasts, focusedDesc });
probes/proof-focus.cjs
// PROOF: dialogs a credential row's actions menu opens (Edit credential, Replace token, Delete) drop keyboard focus
// to <body> when closed. Contacts' row menu, which wires EntityRowActions' triggerRef into restoreFocusRef,
// returns focus to its trigger; the page's own Add credential button does too.
// Mocked boundary: none (real SPA, backend, Postgres); keyboard only (Enter / arrow keys / Escape).
const L = require('./lib.cjs');
async function cycle(page, trigger, itemRe) {
  const t = page.getByRole('button', { name: trigger }).first();
  await t.focus(); await page.keyboard.press('Enter'); await page.waitForTimeout(300);
  for (let i = 0; i < 8; i++) { if (itemRe.test(await L.focusedDesc(page))) break; await page.keyboard.press('ArrowDown'); }
  const item = await L.focusedDesc(page);
  await page.keyboard.press('Enter'); await page.waitForTimeout(600);
  const open = await L.focusedDesc(page);
  await page.keyboard.press('Escape'); await page.waitForTimeout(600);
  return { item, focusWhileOpen: open, focusAfterEscape: await L.focusedDesc(page) };
}
(async () => {
  const browser = await L.launch();
  const owner = await L.freshOrg(browser, 'focus');
  const o = owner.orgId;
  await L.api(owner.ctx, 'POST', `/api/app/connector-credentials?orgId=${o}`, { connectorSlug: 'github', authMethod: 'bearer', name: 'GitHub', secret: { token: 'ghp_focus_000000000000' } });
  await L.api(owner.ctx, 'POST', `/api/app/contacts?orgId=${o}`, { firstName: 'Focus', lastName: 'Control', email: '[email protected]', source: 'manual_import' });
  const page = await owner.ctx.newPage();
  await page.goto(`/dashboard/${o}/settings/connectors`);
  await page.getByRole('button', { name: 'Actions for GitHub' }).waitFor({ timeout: 30000 });
  console.log(`setup: fresh org ${o} with one GitHub credential and one contact`);
  for (const [label, re] of [['Edit credential', /Edit credential/], ['Replace token', /Replace token/], ['Delete', /"Delete"/]]) {
    const r = await cycle(page, 'Actions for GitHub', re);
    console.log(`credential row > ${label}: ${JSON.stringify(r)}`);
    if (r.focusAfterEscape === 'BODY') console.log(`CONFIRMED closing "${label}" (opened from the row menu) leaves focus on <body>`);
  }
  // Control 1: a dialog opened by a real button on the same page.
  const add = page.getByRole('button', { name: 'Add credential' }).first();
  await add.focus(); await page.keyboard.press('Enter'); await page.waitForTimeout(500); await page.keyboard.press('Escape'); await page.waitForTimeout(500);
  console.log(`control: Add credential dialog closed with Escape -> focus ${await L.focusedDesc(page)}`);
  // Control 2: a row menu that wires triggerRef/restoreFocusRef (contacts).
  await page.goto(`/dashboard/${o}/contacts`);
  await page.getByRole('button', { name: 'Open menu' }).first().waitFor({ timeout: 30000 });
  const c = await cycle(page, 'Open menu', /Edit/);
  console.log(`control: contacts row > Edit: ${JSON.stringify(c)}`);
  if (c.focusAfterEscape.includes('Open menu')) console.log('CONTROL a row menu with restoreFocusRef returns focus to its trigger');
  await browser.close();
})().catch((e) => { console.error(e); process.exit(1); });
probes/proof-providers-shared.cjs
// Scope check on the sibling surface that renders the same credential table/dialogs: AI providers.
// Fixture: an `env` provider credential naming a SYNTHETIC environment variable (unset; nothing is resolved or called).
const L = require('./lib.cjs');
async function cycle(page, trigger, itemRe) {
  const t = page.getByRole('button', { name: trigger }).first();
  await t.focus(); await page.keyboard.press('Enter'); await page.waitForTimeout(300);
  for (let i = 0; i < 8; i++) { if (itemRe.test(await L.focusedDesc(page))) break; await page.keyboard.press('ArrowDown'); }
  const item = await L.focusedDesc(page);
  await page.keyboard.press('Enter'); await page.waitForTimeout(600);
  await page.keyboard.press('Escape'); await page.waitForTimeout(600);
  return { item, focusAfterEscape: await L.focusedDesc(page) };
}
(async () => {
  const browser = await L.launch();
  const owner = await L.freshOrg(browser, 'prov');
  const o = owner.orgId;
  const made = await L.api(owner.ctx, 'POST', `/api/app/provider-credentials?orgId=${o}`, { providerSlug: 'openrouter', authMethod: 'env', name: 'OpenRouter env', envName: 'TALE_PROVIDER_KEY_TALE78_SYNTHETIC_A' });
  console.log('fixture env provider credential ->', made.status, JSON.stringify(made.body).slice(0, 160));
  const page = await owner.ctx.newPage();
  await page.goto(`/dashboard/${o}/settings/providers`);
  await page.getByRole('button', { name: 'Actions for OpenRouter env' }).waitFor({ timeout: 30000 });
  const r = await cycle(page, 'Actions for OpenRouter env', /"Delete"/);
  console.log(`AI providers row > Delete: ${JSON.stringify(r)}`);
  if (r.focusAfterEscape === 'BODY') console.log('CONFIRMED the AI providers table (same CredentialRowActions) loses focus the same way');
  // Refusal on the provider surface: rename onto a taken name.
  await L.api(owner.ctx, 'POST', `/api/app/provider-credentials?orgId=${o}`, { providerSlug: 'openrouter', authMethod: 'env', name: 'OpenRouter backup', envName: 'TALE_PROVIDER_KEY_TALE78_SYNTHETIC_B' });
  await page.reload(); await page.getByRole('button', { name: 'Actions for OpenRouter backup' }).waitFor({ timeout: 30000 });
  await page.getByRole('button', { name: 'Actions for OpenRouter backup' }).click();
  await page.getByRole('menuitem', { name: 'Edit credential' }).click();
  const ed = page.getByRole('dialog');
  await ed.getByLabel('Name').fill('OpenRouter env');
  await ed.getByRole('button', { name: 'Save' }).click();
  await page.waitForTimeout(1500);
  const inline = (await ed.innerText()).split('\n').filter((l) => /already|exists|taken|in use/i.test(l));
  console.log(`AI providers rename onto a taken name: inline=${JSON.stringify(inline)} toasts=${JSON.stringify(await L.toasts(page))}`);
  await browser.close();
})().catch((e) => { console.error(e); process.exit(1); });

Activity

  1. yannickmonney commented on Sep 29, 2026

    @yannickmonney
    ContributorAuthor

    This is a browser confirmation of two more sites with the same missing wiring, at e3943c5f5c1e69c39309bb8f5b9cf5e63ce41672. The run used a keyboard only, one fresh synthetic organization, and the real SPA build, backend and PostgreSQL.

    setup: fresh org M6lBVlpsduuZy12BcThfvvjdS75eL9AC
    CONFIRMED Teams row menu > Edit: "Edit team" > Escape -> focus BODY
    CONFIRMED Teams row menu > Delete: "Delete team" > Escape -> focus BODY
    CONFIRMED API keys row menu > Revoke key: "Revoke API key" > Escape -> focus BODY
    CONTROL Contacts row menu > Delete (restoreFocusRef wired): "Delete contact" > Escape -> focus button "Open menu"
    CONTROL WebDAV Revoke button > Escape -> focus button "Revoke"
    --- console/http log --- (none)
    
    • Teams (the team-row-actions.tsx sweep hint above): the row menu's Edit and Delete dialogs drop focus to <body> on Escape.
    • API keys → REST: the row menu's Revoke key does the same on Escape. api-key-row-actions.tsx was not in the sweep list; it renders EntityRowActions without triggerRef and gives its dialog no restoreFocusRef.
    • Controls in the same run: Contacts' wired row menu and WebDAV's Revoke button return focus on Escape.
    • Not exercised: automation-row-actions.tsx and project-row-actions.tsx.

    Confirming the delete is a different gap: focus drops even on Contacts, which is wired. It is filed as #3791, and the fix for this issue does not cover it.

    probes/proof-3715-sweep.cjs (uses lib.cjs from #3791)
    // #3715 sweep: the cancel (Escape) path of row-menu dialogs on Teams (Edit, Delete) and API keys (Revoke),
    // which wire no triggerRef/restoreFocusRef. Controls: Contacts' row menu (wired) and WebDAV's Revoke button.
    // Mocked boundary: none (real SPA, backend, Postgres); keyboard only; one fresh synthetic org.
    const L = require('./lib.cjs');
    const out = [];
    const say = (...a) => { const s = a.map((x) => (typeof x === 'string' ? x : JSON.stringify(x))).join(' '); out.push(s); console.log(s); };
    async function escapeFrom(page, row, item, tag) {
      const trigger = row.getByRole('button', { name: /open menu/i }).first();
      await trigger.focus();
      await page.keyboard.press('Enter');
      await L.focusMenuItem(page, item);
      await page.keyboard.press('Enter');
      const dlg = page.getByRole('dialog');
      await dlg.waitFor();
      const title = (await dlg.innerText()).split('\n')[0];
      await page.keyboard.press('Escape');
      await dlg.waitFor({ state: 'detached' }).catch(() => {});
      await L.sleep(400);
      const f = await L.focusedDesc(page);
      say(`${f === 'BODY' ? 'CONFIRMED' : 'CONTROL'} ${tag}: "${title}" > Escape -> focus ${f}`);
    }
    (async () => {
      const browser = await L.launch();
      const log = [];
      try {
        const o = await L.freshOrg(browser, 'sweep3715');
        say('setup: fresh org', o.orgId);
        const page = await o.ctx.newPage();
        L.watch(page, log);
        const dlg = page.getByRole('dialog');
        await L.goto(page, `/dashboard/${o.orgId}/settings/teams`);
        await page.getByRole('button', { name: 'Create team' }).click();
        await dlg.waitFor(); await page.keyboard.type('Alpha team'); await page.keyboard.press('Enter');
        await dlg.waitFor({ state: 'detached', timeout: 10000 }).catch(() => {});
        await L.sleep(800);
        await escapeFrom(page, page.locator('tbody tr').first(), /Edit/, 'Teams row menu > Edit');
        await escapeFrom(page, page.locator('tbody tr').first(), /Delete/, 'Teams row menu > Delete');
        await L.goto(page, `/dashboard/${o.orgId}/settings/api/rest`);
        await page.getByRole('button', { name: 'Create API key' }).first().click();
        await dlg.waitFor(); await page.keyboard.type('key one');
        await dlg.getByRole('button', { name: /^Create key/ }).click();
        await page.getByText('Your API key').first().waitFor({ timeout: 10000 });
        await dlg.getByRole('button', { name: /^Done/ }).click();
        await dlg.waitFor({ state: 'detached', timeout: 10000 }).catch(() => {});
        await L.sleep(800);
        await escapeFrom(page, page.locator('tbody tr').first(), /Revoke/, 'API keys row menu > Revoke key');
        await L.api(o.ctx, 'POST', `/api/app/contacts?orgId=${o.orgId}`, { name: 'Ada Contact', email: '[email protected]', source: 'manual_import' });
        await L.goto(page, `/dashboard/${o.orgId}/contacts`);
        await escapeFrom(page, page.locator('tbody tr').first(), /Delete/, 'Contacts row menu > Delete (restoreFocusRef wired)');
        await L.api(o.ctx, 'POST', `/api/app/webdav/app-passwords?orgId=${o.orgId}`, { label: 'Finance laptop' });
        await L.goto(page, `/dashboard/${o.orgId}/settings/api/webdav`);
        await page.getByRole('button', { name: /^Revoke/ }).first().focus();
        await page.keyboard.press('Enter');
        await dlg.waitFor();
        await page.keyboard.press('Escape');
        await dlg.waitFor({ state: 'detached' }).catch(() => {});
        await L.sleep(400);
        say(`CONTROL WebDAV Revoke button > Escape -> focus ${await L.focusedDesc(page)}`);
      } finally {
        say('--- console/http log ---', log.length ? '' : '(none)');
        for (const l of log) say(l);
        L.fs.writeFileSync(L.path.join(L.ROOT, 'evidence/proof-3715-sweep.log'), out.join('\n') + '\n');
        await browser.close();
      }
    })().catch((e) => { console.error(e); process.exit(1); });

    This was found by the TALE-70 local audit, which used no production system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugservice: platform

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions