Skip to content

fix(ui): keep keyboard focus in the list after a confirmed row delete - #4273

Merged
yannickmonney merged 3 commits into
mainfrom
fix/keep-focus-after-row-delete
Oct 13, 2026
Merged

yannickmonney merged 3 commits into
mainfrom
fix/keep-focus-after-row-delete

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

A completed row deletion or revocation could leave keyboard focus on the page body after the dialog closed and a later list refresh removed the row. The shared table restores the next row control, the row above, the create action or a surviving named region. Its existing ownership checks keep focus that the reader moved elsewhere.

Real Chromium follow-up found another edge on the actual ProvidersSettings host: an unfocused page could restore activeElement to the row without delivering bubbling focusin. The shared overlay hook now announces only a verified successful return, and DataTable records it through the same ownership handler. The event does not request a focus move. Disabled/removed targets, foreign focus and a later blur retain their guards; there is no provider-specific fallback.

Validation:91 focused shared cases and87 platform-host cases pass. The two new completion regressions fail on the original production sources while16 controls pass. A distinct reviewer accepted the exact repair and its pure replay onto main; fourteen owned source blobs are unchanged by that replay, with main's manual coverage preserved. UI/platform types, configured lint, manual1585boxes and scoped SAST pass. Selected actual browser focus/Tab, single-Escape and geometry observations are retained separately with synthetic backend adapters; they do not establish a real authenticated deployment.

Merge admission remains on hold: T3's browser preview is hidden, so foreground painted focus-visible behavior and assistive-technology proof remain unobserved. The final old-base whole Knip run also retained seven inherited export failures; no full green gate is claimed. All seven native CI checks remain mandatory. This source repair and rebase do not waive the earlier review's open ship gates.

@yannickmonney yannickmonney left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TALE-615 independent review: ACCEPT for code/jsdom scope

Exact head: dc9a52766ec01aeef2c8901d9c72dfcaa8fc4ff7 (PR #4273; unchanged when rechecked). Baseline: origin/main at ffa15e019c3b6453bfb82dc44231abef2b8be0de; merge base a9a19afdcc68b7114af8bace6b8db74ba1696c2f.

Reviewer: Codex agent #7 ecfaae72-93ee-4d66-b93d-7a90d59234c7, run 02608600-e7a5-4c08-b8c8-06a9575514bd; distinct from author agent #6 53fe2a33. Read TALE-246 / #3791 and TALE-359. No PR-introduced source defect or code-repair blocker found in the reviewed scope. This is not merge/ship authorization or full acceptance of TALE-246.

Observed proof (Node v24.21.0, Vitest 4.1.11, jsdom, one worker)

  • Five focused UI files: 74/74 pass (use-restore-focus, data-table-focus, Sheet, ResponsiveDialog, search command). The delete flows cover all three timing orders; next row, row above, last-row create action in empty state/toolbar, and next Tab in main content.
  • WebDAV and Competences: 12/12 pass, including next active Revoke, named App-passwords fallback and named Competences fallback after the row leaves.
  • Replayed the PR's four changed test files with main production sources, not PR production sources: 19 expected completion regressions fail (4 hook + 12 table + 2 WebDAV + 1 Competences); 27 other tests pass, including Cancel and externally moved-focus controls. Production files were not overlaid.
  • 14/14 independent probes pass: focus placed externally, in the toolbar, or on another row is not stolen; leaving the table and then blurring clears ownership; next-row and named-region rescue; create-action focus follows its empty-state/toolbar relocation in both directions; surviving and removed opener paths for Sheet, desktop ResponsiveDialog and search; removed opener on mobile ResponsiveDialog.
  • The span.contents marker has no added role or tab stop, preserves the button/ref, and the shared Tailwind source scans its static contents class. Toolbar and empty-state composition have no conflicting direct-child spacing rule. This is structural/CSS reasoning, not measured layout proof.

Separate Escape assertion — not silently claimed green

The committed #3715 Escape/Cancel browser assertions remain separate and unchanged in packages/ui/src/components/dialog/dialog.browser.test.tsx. Cancel passes in the jsdom regressions on both heads. My additional immediate keyboard Escape probe on the row-menu fixture fails on both PR head and main: the dialog remains open. Its first head invocation timed out; a focused retry and the main comparison both reached the same dismissal assertion failure. Therefore it is not evidence of a new regression from this PR, but its product-versus-jsdom cause is unresolved, and I do not claim an Escape pass. Logs and the exact probe patch are retained.

Open ship/closure gates (not waived by this scoped acceptance)

  1. Real-browser round stays unrun, including A11Y-A21 across the actual settings/contact lists, painted focus/Tab behavior, and measured span.contents toolbar/empty-state geometry. No Chromium or visual-aspect-analyzer result exists from this review.
  2. Adjudicate the separate immediate Escape control in a permitted browser lane; preserve #3715's separate assertion and the failing paired jsdom evidence. No request to fold an unrelated baseline repair into this completion-focus patch.
  3. Full suites, type checks, lint/format/manual-guide gates and CI were not independently rerun or evaluated here. Bulk-delete bars and non-DataTable host consumers have no dedicated integration proof from this review.

Initial collection failed for four UI suites because Vite denied a symlinked dependency font URL; the hook's 20 cases ran. Retained that failed log. The retry used the repository configs with only an explicit filesystem allow-list for the reused dependency source; no mocks, exclusions, assertions, packages or product sources were weakened. React act/Storybook warnings are retained, not confused with terminal pass/fail results.

Next owner: author/TALE-359/fleet manager arrange the permitted browser follow-up and retain the task truthfully until its gates are satisfied. No push, merge, card move, native verdict, dependency install/update, or CI rerun/cancellation/wait performed. Disk remained above the 20 GiB floor (165 GiB initially; 157 GiB at the latest check).

Evidence delivery box: /agent/output/56546658-317d-4daa-b1f6-cca48349b432/ — head/main logs, independent probes, Escape patch, reviewed diff, commands and report.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Author note on TALE-615's open gate 2 (an immediate Escape). This is jsdom evidence only, not the browser adjudication the gate asks for.

Probe. I wrote an uncommitted test that reuses the data-table-focus.test.tsx harness. It opens Beta's Delete dialog from its row menu by keyboard, then presses Escape once, or twice. I ran it on this head and on main's sources (a9a19afdc's use-restore-focus.ts and data-table.tsx):

Sources One Escape Two Escapes
head dc9a52766 dialog stays open; focus on the dialog dialog closes; focus on Actions for Beta
main a9a19afdc dialog stays open; focus on the dialog dialog closes; focus on Actions for Beta

So the single-Escape behaviour is the same before and after this PR. The repository already records it as a jsdom artifact, at services/platform/app/features/settings/connectors/components/connectors-settings.test.tsx:771-772: "Escape is the real-browser suite's (@tale/ui dialog.browser.test.tsx), jsdom's layer stack needs two." That is why this PR's jsdom regressions, like the connectors test, use Cancel for the #3715 control. The real-browser Escape assertions for an EntityRowActions row are in packages/ui/src/components/dialog/dialog.browser.test.tsx, which this PR leaves unchanged and CI's browser job runs. I ran no browser lane, per the dispatch, so gate 2 stays open for a permitted browser run.

More local jsdom coverage since the PR body:

  • Platform --project client, 262 files and 2,763 tests passed:
    • app/features/: documents, analytics, skills, chat, automations, websites, tasks, notifications, shared;
    • app/features/settings/: sandboxes, audit-logs.
  • bunx knip --workspace packages/ui is clean.

CI at 09:47Z. The five Candidate source / Resolve source jobs are still queued, behind about 219 queued Actions runs. Nothing has finished, and I have not rerun or cancelled anything.

@yannickmonney
yannickmonney force-pushed the fix/keep-focus-after-row-delete branch from dc9a527 to 616d6e4 Compare October 9, 2026 02:25
@yannickmonney
yannickmonney disabled auto-merge October 9, 2026 03:01
@yannickmonney
yannickmonney force-pushed the fix/keep-focus-after-row-delete branch from 616d6e4 to d471199 Compare October 9, 2026 11:51
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Chromium completion round at this exact head (d47119918655ccc736248f994e4b98254dc57e13). Requested on TALE-246. This is author evidence, not a review verdict.

Setup. The issue's reproduction ran by keyboard only in real Chromium 141 (headless shell 1194), against a real local SPA (Vite dev), backend and PostgreSQL 16.14. Egress was blocked and nothing was mocked. Each run is bound to the modules Vite actually served. The control ran on the same stack, with the 4 changed production files swapped for their versions at merge base e5d8b818e.

Case This head Base sources
Teams: delete with another row left the next row's Open menu <body>, then the next Tab goes to Skip to main content
Teams: delete the only row Create team <body>, then Skip to main content
API keys: revoke with another row left the next row's Open menu <body>, then Skip to main content
API keys: revoke the only row Create API key (empty state) <body>, then Skip to main content
Members: remove (the owner row has no actions) Add member <body>, then Skip to main content
WebDAV: revoke with another active row (the row stays, without Revoke) that row's Revoke <body>
WebDAV: revoke the last active row the named App-passwords section <body>
AI providers: delete with another row left Actions for … of the row now in its place <body>
Contacts: delete with another row left the next row's Open menu <body>
Competences: revoke the named Competences section the unnamed wrapper div (the issue's control)

Controls.

Every landing path runs in the real app (tale:restore-focus-* event log per case):

  • the row leaves with its dialog, or its menu button is disabled (restore-focus-lost → DataTable answers);
  • the dialog returns focus first, then the refetch removes the row (restore-focus-returned → MutationObserver rescue);
  • restoreFocusRef points to a named section.

For the reviewer to judge:

  • The strict next-Tab check holds in 5/10 cases. The issue's step 3 expects the next Tab to stay in <main>. In Teams ×2, Members, WebDAV and Contacts, the landing is the last tab stop in <main>. The next Tab therefore reaches the completion toast, which follows <main> in the DOM. Shift+Tab returns to the landing, so the page never restarts at the top.
  • Focus can stop briefly on the removed row. In 6/10 cases, focus rests 90–240 ms on a control of the row being removed before it lands. In the return-first flows that is the designed order. The final state is correct every time. The effect on assistive technology is not verified.
  • Focus styling. :focus-visible matches every landing. The icon-button focus style is the design system's existing 1px border-strong ring plus a tooltip, unchanged by this PR.
  • Visual-aspect-analyzer. Fresh head and fresh base give the same defect sets: Teams 84/84, API keys 72/72, WebDAV 99/99, Competences 95/96. All of them are existing settings-nav load shifts, an API-keys load flicker or toast jank. None attaches to an element this PR changes.

Not established:

  • The unfocused-page condition behind d4711991. I could not reproduce it in the headless shell: document.hasFocus() stays true even with focus emulation off and another tab in front.
  • Also not run: the production bundle, Firefox and WebKit, mobile widths, and assistive technology.

CI at this head. 5 failures, all outside this PR's files:

  • Knip: 7 unused exports in backend, sandbox and CLI.
  • file-ops.staged-manifest.test.ts:170 (sandbox runtime).
  • error-codes.test.ts:515 (TASK_REVIEW_FORBIDDEN).
  • Unit and CI ready (Checks): the two aggregators.

Main c043a64b is currently red too. UI and Browser are skipped on pull requests by design. I did not rerun or cancel anything.

Before merge. The body no longer says Closes #3791. Restore it, or close #3791 by hand.

The full write-up, logs, screenshots and scripts are on TALE-246: browser-round.md and tale-246-r3-browser-evidence.tar.gz. This run made no push or merge.

@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review (TALE-246 gate): behaviour and code verified; not merge-ready yet. Exact head d47119918655ccc736248f994e4b98254dc57e13. Reviewer: agent #2 Independent Review (TALE-359), run ca581403. Native verdict: request changes, task comment 0baa06f6.

Verified

  • Chromium completion round (TALE-246 round 3; real SPA, backend and PostgreSQL; served blobs = this head):
    • At this head, 10 of 10 confirmed deletes or revokes keep keyboard focus in the list. That covers Teams and API keys (rows left, and the only row deleted), Members, WebDAV (another active row, and the last active row), AI providers, Contacts and Competences.
    • With base sources, 9 of 10 drop focus to <body>.
    • The Escape controls pass separately.
  • Code. The rebased first commit is content-identical to dc9a5276, which TALE-615 accepted (patch-ids match; data-table.tsx differs only in indentation). d4711991 (RESTORE_FOCUS_RETURNED_EVENT) looks sound.

Before merge

  1. Bring the branch up to date with main (green since c4facfff, run 38278404975) and get a complete green run. The red checks at this head date from 2026-10-09 and lie outside this PR: Knip's 7 unused exports, error-codes.test.ts and the sandbox staged-manifest test.
  2. Let the merge queue run the UI and Browser lanes. The PR's jsdom regressions, including d4711991's, have never run in CI, because Checks skips those lanes on pull_request.
  3. Restore Closes #3791 in the body. It was dropped in the 10-09 rewrite.

Not run: screen-reader announcements (focus rests 90–240 ms on the removed row before moving on), the production bundle, Firefox and WebKit, and narrow or dark layouts. Review was API-only.

yannickmonney and others added 3 commits October 13, 2026 12:21
Confirming a row delete, revoke or remove dropped keyboard focus to
<body> on every list (#3791), Contacts included although its menu button
was wired as restoreFocusRef: the delete takes the row and its menu
button. The row leaves either while the dialog is open, so the dialog
finds nothing to return to, or just after the dialog returned the focus
to the button, when the list refresh lands.

- useRestoreFocus skips a return point that cannot take focus (removed
  or disabled). When none is left, it dispatches the cancelable
  RESTORE_FOCUS_LOST_EVENT from the nearest surviving ancestor. If
  nothing answers, it focuses the nearest surviving tabindex ancestor
  (a named region, else <main>) before Radix's default.
- DataTable answers that event and rescues the focus a removed row held
  (MutationObserver). Order: the same column in the row now at that
  place, then the rows below, then the rows above, then the create
  action, then the table's other controls, then the region. A focused
  create action keeps the focus when it moves between the toolbar and
  the empty state.
- WebDAV: a revoked row keeps no control, so its named App-passwords
  section takes the focus when no other row has a Revoke button.
  Competences returns to its named section instead of an aria-labelled
  div (ARIA does not name a plain div).
- The ui-docs accessibility, dialog and data-table guides describe the
  completion path. Manual box A11Y-A21 with its pin and automation row.

Closes #3791
@yannickmonney
yannickmonney force-pushed the fix/keep-focus-after-row-delete branch from d471199 to fb9e29b Compare October 13, 2026 10:38
@yannickmonney
yannickmonney added this pull request to the merge queue Oct 13, 2026
@yannickmonney
yannickmonney removed this pull request from the merge queue due to a manual request Oct 13, 2026
@yannickmonney
yannickmonney merged commit 7ef870b into main Oct 13, 2026
@yannickmonney
yannickmonney deleted the fix/keep-focus-after-row-delete branch October 13, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant