Skip to content

fix(web): return a list to the page and sort it was left on - #1924

Merged
joshunrau merged 2 commits into
mainfrom
fix/return-to-list-page
Nov 18, 2026
Merged

joshunrau merged 2 commits into
mainfrom
fix/return-to-list-page

Conversation

@thomasbeaudry

@thomasbeaudry thomasbeaudry commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Following a Return link from a row's page now reopens the list on the page and sort the user left, instead of page one. Before, opening a user from page 2 of /admin/users and clicking Return landed back on page 1. The same was true of /admin/permission-sets/$id, /datahub/subjects/$id and /datahub/instruments/$id.

Changes

  • Every client-mode table remembers its page and sort for the session, by name, and restores them when its page is opened again. Signing out reloads the app and clears them.
  • A list left while searching or filtering reopens on page one with its sort kept, because the search box always opens empty and the saved page would point at different rows.
  • A table stays on its page when its rows are refetched, for example after editing a user and returning. Before, any refetch also reset it to page one. It still returns to page one when the search, a column filter, the sort, or a filter its page applies to the rows itself changes.
  • If a refetch leaves fewer pages than the one shown, the table moves to the last page.
  • Tables bound to one subject, instrument, series or group remember their place separately. Switching group shows that group's own saved page.
  • Importing libui's DataTable anywhere in apps/web outside @/components/DataTable is now a lint error, so a new table cannot bring the bug back.

Decisions

  • The fix lives in ODC rather than libui. libui's client-mode initialState takes no pagination, so the wrapper reaches the Tanstack table through a column header renderer, the one place every table renders, including under disableSearch. It then sets autoResetPageIndex: false and resets on filter and sort changes itself. Adding the missing API to libui would be cleaner, but it takes a cross-repo PR and a release first.
  • Server-mode tables (audit logs and the repository sync log) pass through untouched. Their callers already hold the page and sort they request, and neither has a Return link.
  • A list's rows filtered outside the table, such as the subjects page's minimum record count, are declared through a pageResetKey prop. The wrapper cannot otherwise tell such a change of data from a refetch of the same rows.
  • Saved views live in a module-level Map (src/services/table-views.ts) rather than the Zustand store. Many unit tests mock @/store with partial state, and this state has no other reader.

Risks

  • The wrapper depends on two libui internals: every header renders before effects run, and the store rebuilds table options from the previous ones on every update. A libui release that breaks either would stop the page being kept or restored. It would fail visibly (unit tests and list-return.spec.ts) rather than corrupt anything.

Notes

list-return.spec.ts fails all three of its cases against main and passes on this branch. The permission-sets page object now searches for a set before acting on it, because the list is shared across specs and can run past one page.

Adversarial review

Reviewed at commit dbe24c0. pnpm check: green.
Follow-up 0b77c47: rebased onto main (after #1923 and #1917, resolving one import conflict in admin/users/index.tsx), and the list-return subjects case now seeds ids that differ within the nine characters the list shows, which CI exposed; no new code outside that spec.

Findings

  1. apps/web/src/components/DataTable/DataTable.tsx:66 — autoResetPageIndex: false keeps the page when data changes because of a filter applied outside the table or a group switch, leaving the user mid-way through a different row set — reset to page one when the caller's selection changes
  2. apps/web/src/components/DataTable/DataTable.tsx:92 — the unmount cleanup saves under the tableName of the first render, so a table renamed in place (subjects list on a group switch) saves and restores under the wrong key — remount the client table keyed by tableName
  3. apps/web/src/components/DataTable/DataTable.tsx:96 — a table that mounts before its rows load clamps the restored page to zero — clamp only once rows exist
  4. testing/src/specs/list-return.spec.ts:47 — the permission-sets case can flake when another worker creates a set that sorts ahead of the recorded row — give the spec's sets a prefix that sorts first
  5. apps/web/src/components/DeleteRemoteAssignments/DeleteRemoteAssignments.tsx:224 — one global tableName for a table whose rows depend on groupId (and SourceStep's likewise) carries a page across groups — key them by group

Fixed

    1. New pageResetKey prop, passed by the subjects list (minimum records), subject records (instrument and date) and instrument-hub records (URL filters); group switches are covered by 2.
    1. ClientDataTable is keyed by tableName, and group-scoped tables carry the group in their name.
    1. The clamp skips while data is empty.
    1. The spec's sets are named !List Return <id> NN, which the name-ordered list puts first.
    1. Both tables are now named per group, as is the instrument hub's.

Attestation

I, Claude Opus 5.5, attest that the review block above reports the adversarial review as it ran on the commit named, with every finding it returned.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the Status: Needs Rebase Automated: conflicts with main; the author rebases label Nov 18, 2026
@thomasbeaudry
thomasbeaudry force-pushed the fix/return-to-list-page branch from dbe24c0 to 96a111a Compare November 18, 2026 17:33
@github-actions github-actions Bot added Status: Waiting on Review Automated: unreviewed, pushed since the last review, or review re-requested Status: CI Failing Automated: a check failed; the author fixes it and removed Status: Needs Rebase Automated: conflicts with main; the author rebases Status: Waiting on Review Automated: unreviewed, pushed since the last review, or review re-requested labels Nov 18, 2026
thomasbeaudry and others added 2 commits November 18, 2026 13:33
The Return link on a row's page, such as /admin/users/$userId, always
reopened its list on page one, because libui's DataTable forgets its
pagination when it unmounts. Every table now goes through
@/components/DataTable, which remembers each table's page and sort by
name for the session, keeps the page across refetches, and returns to
page one only when the search, a filter or the sort changes. An eslint
rule rejects importing libui's DataTable anywhere else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e list shows them

The subjects list shows nine characters of an id, and every id from
createSubject starts subject_, so two pages could read alike and the
spec could not tell it had changed page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thomasbeaudry
thomasbeaudry force-pushed the fix/return-to-list-page branch from 96a111a to 0b77c47 Compare November 18, 2026 18:33
@github-actions github-actions Bot added Status: Waiting on Review Automated: unreviewed, pushed since the last review, or review re-requested Status: CI Failing Automated: a check failed; the author fixes it and removed Status: CI Failing Automated: a check failed; the author fixes it Status: Waiting on Review Automated: unreviewed, pushed since the last review, or review re-requested labels Nov 18, 2026
@joshunrau
joshunrau merged commit 838004d into main Nov 18, 2026
7 of 8 checks passed
@joshunrau
joshunrau deleted the fix/return-to-list-page branch November 18, 2026 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Waiting on Review Automated: unreviewed, pushed since the last review, or review re-requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants