feat: generic back button with preserved list state - #177
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
BackButtoncomponent (src/lib/components/common/BackButton.svelte): useshistory.back()when there is browser history (preserves filters/scroll), falls back togoto(href)on direct entry. Label viacommon_backi18n (en/pl).src/lib/utils/url-state.ts):readIntParam/readParam/writeSearchParams. Synced withgoto(..., { replaceState, keepFocus, noScroll })so SvelteKit's history state is preserved.admin/users(q,role,limit,offset,sort), contestparticipants(limit,offset,sort), contesttasks(added+assignable:a_*/x_*limit/offset/sort/search), teacher contestsubmissions(user,task,limit,offset).Bug fixed during implementation
writeSearchParamsoriginally used rawhistory.replaceState(null, ...), which clobbered SvelteKit's navigation state and broke popstate handling — back changed the URL but never re-rendered. Switching togotowithreplaceStatefixed it.Verification
pnpm run check: 0 errors