Skip to content

fix(platform): hand a focused retry to the list when a refresh swaps it - #3937

Merged
yannickmonney merged 2 commits into
mainfrom
fix/list-error-state-focus
Sep 29, 2026
Merged

yannickmonney merged 2 commits into
mainfrom
fix/list-error-state-focus

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #3814 (review r4134167039), part of #3777. The review asked for a sweep of the other failure notices after a keyed alert dropped a focused Try again. #3814 fixed the four keyed alerts before it merged. The sweep found one more path that loses focus the same way, and this PR fixes it.

The problem

A knowledge list that never loaded shows DataTable's error state (#3814 put Try again there instead of "No knowledge entries yet"). A refresh the reader did not start swaps that state for the loading state while it runs:

  • the tab regaining focus (the app refetches failed reads on focus),
  • another session's change,
  • the event stream reconnecting.

A Try again the reader had focused, but not pressed, was removed with it, and the focus dropped to the page body. Focus stayed on the body while the refresh ran, after the refresh failed again, and after the read healed.

Reproduced in Chromium on the CI bundle of #3814's merged head 4afccb13b, against a local synthetic stack, with two triggers: another session's hub upload and a window refocus. The Documents list uses the same state.

What changed

  • useFocusHandoff (@tale/ui, internal) is CatalogLoadError's handoff, extracted and now shared. It is a callback ref: when its element leaves with the focus inside, the focus goes to onFocusLost a frame later, once the replacement has mounted. Focus the reader moved elsewhere stays where it is. CatalogLoadError now uses it, with no change in behaviour.
  • ErrorDisplayCompact gains an optional onFocusLost, and DataTable gains an optional onErrorFocusLost for its error state. Both are additive, and nothing changes for callers that pass neither.
  • The Knowledge entries and Documents lists pass their region, the same target a manual retry already moves focus to.
  • Docs: ui-docs data-table.md and list-page.md, manual box KNOW-A7 (window-refocus path), and the automation-map row.

Not changed:

How I verified it

  • New regression tests
    • The knowledge list, run through the real hooks, adapter and retry policy against a closed synthetic transport. A focused, unpressed Try again in the error state lands on the list region when a background refresh starts. It stays there when the refresh fails again (four attempts) and when the read heals. Focus moved elsewhere stays put.
    • The Documents list: the same handoff.
    • DataTable and ErrorDisplayCompact unit tests.
  • Mutation checks, one at a time. Each broke exactly the tests that cover it:
    • Unwiring the list or the Documents host: 1 test each.
    • ErrorDisplayCompact dropping the ref: 2 tests.
    • DataTable dropping the prop: 1 test.
    • The hook never handing off: 3 unit tests plus the version-history integration test.
  • Local runs
    • The related @tale/ui suites (error boundaries, data table, catalog, useListPage, entity view): 205/205.
    • The related platform suites (both lists, version history, project files, paginated hook, home inbox): 68/68.
    • ui-docs: 82/82.
    • lint:manual, check-guide, oxfmt --check and oxlint --type-aware --type-check on the changed files are all clean.

Native Chromium on the exact head 2c259ee31. CI bundle served locally, against a local backend with synthetic data only. The read under test answered 503; background refreshes came from a second session's writes or a window refocus. No screen reader was run; focus and roles were read from the DOM and the accessibility tree.

  • Knowledge list, cold failure: Try again focused and not pressed. Triggers: another session's hub upload, and a window refocus. Focus is on the Knowledge entries region while the refresh runs, after it fails again (4 requests), and after it heals. On fix(platform): recover failed knowledge, history and folder reads #3814's merged head 4afccb13b, the same steps left focus on the page body in all three phases.
  • Documents, cold failure (in a folder with no subfolders), window refocus: the same, on the Documents region.
  • Paths fix(platform): recover failed knowledge, history and folder reads #3814 already fixed, re-checked because CatalogLoadError now uses the shared hook:
    • Version history: the Try again node and its alert node both stay the same through a failed background refresh. A manual Retry moves focus to the section and keeps it there through the re-failure.
    • Moving to Edit: a reader who moves to Edit while the background request is pending stays on Edit, whether the request fails again or heals the read.
    • Heal with Try again still focused: the refresh that heals hands focus to the section.
    • List and Files notices: the same Try again node stays focused through a failed background refresh, and focus moves to the region or group when the read heals.
  • Cold manual retry: Enter moves focus to the region, and the list recovers without a reload. Checked on a477ad76b, which has the same app code.

CI at 2c259ee31: every check passes. The first run, on a477ad76b, failed the Browser job in use-resizable.browser.test.tsx: a Sheet width of 383.9999 against 384. That test failed on main at 19f18f6cb the same way and passed on the next main run, so it is a flake unrelated to this change. I rebased onto main to get a fresh run.

Review of #3814, swept past the keyed alerts: with nothing loaded, a list's
failure is DataTable's error state, and a refresh the reader did not start
(the tab regaining focus, another session's change) swaps it for the loading
state. A Try again the reader had focused went with it, and the focus
dropped to the page (Chromium, the knowledge list at 4afccb1).

- `useFocusHandoff` is CatalogLoadError's handoff, now shared: a callback
  ref whose element, leaving with the focus inside, hands the focus to
  `onFocusLost` a frame later. Focus the reader moved elsewhere stays.
- ErrorDisplayCompact takes `onFocusLost`; DataTable passes its new
  `onErrorFocusLost` to its error state.
Review of #3814, swept past the keyed alerts: a knowledge list that never
loaded shows the table's error state, and a refresh the reader did not start
swapped it for the loading state, taking a focused Try again and dropping
the focus to the page — while the refresh ran, after it failed again, and
after it healed (Chromium at 4afccb1: another session's hub upload, and
the window regaining focus). The documents list shares the state.

- Both lists pass their region as the table's `onErrorFocusLost`, the
  target a manual retry already moves focus to. Focus the reader moved
  elsewhere stays.
- Regression tests: a focused, unpressed Try again in the error state
  through a background refresh that fails again and then heals, and focus
  moved elsewhere. Manual box KNOW-A7 adds the window-refocus path.
@yannickmonney

Copy link
Copy Markdown
Contributor Author

Independent review complete at 2c259ee. No blocker found in this scoped handoff.

I ran 60 shared component tests and20 Knowledge/Documents client tests locally. In Chrome, a local harness rendered this exact head's real DataTable and useListReadRecovery: a focused retry handed focus to the named list region during background loading, repeated failure and recovery; focus deliberately moved to another connected control stayed there; Tab+Enter retry recovered with region focus. The harness uses synthetic state, not a native server or full authenticated session. Documents wiring is covered by its executed client regression. No production tests.

React Doctor:91/100, one DataTable complexity warning, no errors. Reused dependency packages mean the local run is complemented by exact-head CI, not presented as a fresh frozen-lock install. All50 reported CI checks are completed without a failing/pending result.

@yannickmonney
yannickmonney merged commit 55440ae into main Sep 29, 2026
50 checks passed
@yannickmonney
yannickmonney deleted the fix/list-error-state-focus branch September 29, 2026 17:50
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