Skip to content

feat: generic back button with preserved list state - #177

Merged
HermanPlay merged 1 commit into
masterfrom
feat/back-button
Aug 16, 2026
Merged

HermanPlay merged 1 commit into
masterfrom
feat/back-button

Conversation

@HermanPlay

Copy link
Copy Markdown
Member

Summary

Adds a generic back button to all sub-pages and preserves list view state (filters, sort, pagination, search) in the URL so returning via the back button restores the exact previous view, including scroll position. Closes #174.

Changes

  • BackButton component (src/lib/components/common/BackButton.svelte): uses history.back() when there is browser history (preserves filters/scroll), falls back to goto(href) on direct entry. Label via common_back i18n (en/pl).
  • Placed on 16 sub-pages: teacher contest tasks / task-user-stats / submissions / user-stats / collaborators / groups / participants / registration-requests, group detail + collaborators, task collaborators, user contest detail / results / task detail, submission detail, available-task detail.
  • URL state persistence (src/lib/utils/url-state.ts): readIntParam/readParam/writeSearchParams. Synced with goto(..., { replaceState, keepFocus, noScroll }) so SvelteKit's history state is preserved.
  • Pages synced: admin/users (q,role,limit,offset,sort), contest participants (limit,offset,sort), contest tasks (added+assignable: a_*/x_* limit/offset/sort/search), teacher contest submissions (user,task,limit,offset).

Bug fixed during implementation

writeSearchParams originally used raw history.replaceState(null, ...), which clobbered SvelteKit's navigation state and broke popstate handling — back changed the URL but never re-rendered. Switching to goto with replaceState fixed it.

Verification

  • pnpm run check: 0 errors
  • prettier clean on new TS
  • Deployed locally: submissions → set filters → open detail → back → filters, pagination and scroll restored

Add a reusable BackButton (history-aware with fallback href) on all
sub-pages, and persist list view state (filters, sort, pagination,
search) to URL search params so browser back restores it.

- BackButton component; common_back i18n (en/pl)
- url-state helpers; URL state synced via goto replaceState to keep
  SvelteKit history intact (fixes back not re-rendering)
- applied to: admin/users, contest participants/tasks/submissions,
  teacher contest/group/task sub-pages, user contest/results/task,
  submission detail, task detail
@HermanPlay
HermanPlay merged commit 805541a into master Aug 16, 2026
1 check passed
@HermanPlay
HermanPlay deleted the feat/back-button branch August 16, 2026 21:54
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.

Implement generic back button

1 participant