Skip to content

fix(platform): preserve notification switch focus while saving - #4265

Merged
yannickmonney merged 1 commit into
mainfrom
fix/notification-preference-keyboard-focus
Oct 4, 2026
Merged

yannickmonney merged 1 commit into
mainfrom
fix/notification-preference-keyboard-focus

Conversation

@yannickmonney

Copy link
Copy Markdown
Contributor

Summary

  • Keep ordinary notification preference switches focusable during saves, using their existing aria-busy state instead of native disabling.
  • Guard the toggle handler while a save is pending, preserving the existing single-save behavior for keyboard and pointer interactions.
  • Leave the always-on, disabled Review requests switch unchanged.

Verification

  • Added five deferred-save jsdom regressions: Space on Task assigned to me, Mentions and actionable email; pending focus and Tab order; blocked duplicate/cross-switch saves; success/failure focus retention and retry.
  • Against unchanged main a9a19afdc: all five new cases fail on the pending native-disabled state; eight existing tests pass.
  • With the fix: preference page and adjacent SettingsToggleRow suites pass, 21/21 tests (single worker).
  • Targeted type-aware oxlint and oxfmt check pass on both changed files. Scoped TypeScript semantic/syntax diagnostics pass on both changed files, with the normal test setup included (0 diagnostics; 2 GiB heap cap). git diff --check passes.
  • Local suite uses the existing Vitest UI configuration with a delivery-box-only filesystem allow-list override because the isolated worktree reuses the standing clone's dependencies.
  • Per light-work resource admission, no browser/server stack, full suite, whole-workspace typecheck, CI rerun or cancellation. Real-Chrome focus/visual validation remains for independent QA; jsdom asserts the native-disable cause and keyboard focus/tab behavior, not Chrome's AX tree.

Closes #3819

@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.

Independent review of PR #4265 at 09d275795122de984e9e950dee0ccee703cf7364: accepted, no blockers

Reviewer: agent #4 5f5307c9, run 79fb2fa4 (TALE-606). Author: Codex #2 7b86c233, run 8de68806 (TALE-251). The contract is TALE-251 / #3819. Base is main a9a19afdc, which is also the PR's merge base, so this head already includes current main.

Contract checks (jsdom)

Check Result Evidence
Focus stays on the switch during the pending save, and the next Tab continues from it Pass The PR's tests cover three switches. My probe P1/P4 drives the real useSetNotificationPreferences → useBackendMutation → TanStack path, with only backendFetch mocked. The switch stays enabled, aria-busy="true" and focused, and Tab lands on the next switch (Task status changed).
A second activation during the save sends no duplicate Pass Real-hook probe, while the save is pending: Space, Enter, user.click and fireEvent.click on the same switch, plus a click on Mentions. backendFetch is called once. After the save settles, one more Space sends exactly one save. Mutation check: removing if (isPending) return; turns the 3 PR keyboard tests red (called 1 times, but got 2 times) and probe P1 red (6 calls).
A failure reverts the value and keeps focus Pass There is no optimistic update. The switch renders server data, so it never shows the new value before a successful refetch. After a rejected save, real-hook probe P2 shows aria-checked="true" (the stored value), focus still on the switch, aria-busy="false", the switch enabled, and a retry sending again. The PR's failure test asserts the same with the stubbed hook.
Locked Review requests control unchanged Pass The diff changes disabled={isLockedOn || isPending} to disabled={isLockedOn}. For taskReview, isLockedOn is always true, so the switch is disabled in every state, as before. aria-busy={isPending} is unchanged. Probe P1: disabled with aria-checked="true" during and after the save, and a click on it sends nothing. The three existing #2651 tests pass.
Regression fails on main Pass The PR's test file on main's source: the 5 new tests fail at expect(toggle).not.toBeDisabled() and the 8 existing tests pass. My probe on main: P1 fails at the same line. P4 shows that on main a pending Tab does not reach the next switch, because every switch is disabled, so the PR's Tab assertion is a second tripwire beyond the disabled check.

What I ran (at the exact head unless noted)

  • bunx vitest run --config vitest.ui.config.ts --maxWorkers 1 on the page test file plus settings-toggle-row.test.tsx: 21/21 pass (13 + 8).
  • The same page test file on main a9a19afdc's source: 5 failed / 8 passed, and the 5 failures are exactly the new tests.
  • My real-hook probe (4 tests): 4/4 pass at head; 1 failed / 3 passed on main (P1, at not.toBeDisabled()).
  • Guard mutant (if (isPending) return; removed): 4 failed / 13 passed (the 3 PR keyboard tests and probe P1). Restored with git checkout.
  • bunx oxlint --type-aware on both changed files: exit 0. oxfmt -c .oxfmtrc.json --check: both files clean.

The author's claims match what I reproduced: 5 new tests red on main, 21/21 at head, lint and format clean. I did not reproduce the author's scoped TypeScript run.

Non-blocking notes

  1. Same-tick double activation (already on main, not a regression). Two click()s in one task, before React re-renders with isPending = true, send 2 saves on both head and main (probe P3: 2 calls on each). The guard reads isPending from render state, and TanStack only notifies after a macrotask. Human input can't produce this in practice. A ref-based in-flight flag would close it if wanted.
  2. The PR's tests stub the mutation hook with a synchronous useState stand-in, so they don't exercise TanStack's real pending timing. My real-hook probe shows the same behaviour, so this isn't a blocker, but a test on the real hook would be sturdier.
  3. During a save, the other switches silently ignore activation. They look enabled with aria-busy="true" while the handler drops the input. That meets the contract. Optionally, aria-disabled on the other rows would also tell assistive-technology users why nothing happened.
  4. jsdom has no Chrome focus fixup. On main, jsdom keeps focus on the disabled switch (probe P4). The jsdom proof of the bug is therefore the disabled attribute plus the Tab order, not the focus drop itself.

Unrun proof

  • Real Chrome and the AX tree: the focus drop on main, focus retention at head, the screen-reader announcement of aria-busy, and the toast's focus behaviour. This was a light-only slot.
  • TypeScript type-check of the changed files (the author reports 0 diagnostics; CI runs it).
  • The full platform suite and a whole-workspace tsc.
  • CI: at 08:41Z all 5 workflows (Build, Checks, Commitlint, E2E, SAST) were queued at "Candidate source / Resolve source". I did not wait on, rerun or cancel them, and I count none of them as passing.

Verdict: accept at 09d275795122de984e9e950dee0ccee703cf7364, with no blockers. Merging stays with TALE-359 and needs green CI at this head.

@yannickmonney
yannickmonney merged commit 3aebb92 into main Oct 4, 2026
@yannickmonney
yannickmonney deleted the fix/notification-preference-keyboard-focus branch October 4, 2026 14:11
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.

Notification preference switches drop keyboard focus immediately after Space

1 participant