Repository navigation
feat: the admin Settings page keeps its tab in the address (?tab=) - #534
Merged
Merged
Conversation
Reloading Settings always went back to the first tab. The open tab now lives in `?tab=`: a reload keeps it, back and forward move between tabs, and a link can open a specific tab. A click pushes a history entry with the native History API, which Next.js syncs into useSearchParams, so the switch stays instant and unsaved edits are kept. An unknown tab, or one the backend mode does not show (`auth` in Plex mode), shows the first tab and leaves the address alone. Co-authored-by: NichCodes <90598280+NichCodes@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kikootwo
marked this pull request as ready for review
November 2, 2026 17:19
This was referenced Nov 2, 2026
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
Reloading the admin Settings page always went back to the first tab. The open tab now lives in the page address,
?tab=, like the other admin pages keep their state: a reload keeps the tab, back and forward move between tabs, and a link can open a specific tab (for example/admin/settings?tab=paths).Changes
src/app/admin/settings/hooks/useSettingsTabUrlState.ts(new): reads the tab from?tab=on every render and only accepts a tab the current backend mode shows (getTabs(backendMode)). Anything else, such asauthin Plex mode or a typo, shows the first tab and the address is left alone, so there is no redirect loop and no flash of another tab. A click pushes a history entry withwindow.history.pushState, which Next.js syncs intouseSearchParamswithout a server round trip, so switching tabs is as instant as before. The first tab is written as no parameter.src/app/admin/settings/page.tsx: uses the hook instead of local state. Unsaved edits are kept when switching tabs, as before (same page instance, nothing remounts). The page is wrapped in a Suspense boundary foruseSearchParams, with the existing spinner as the fallback.tests/helpers/mock-next-url-history.ts(new): anext/navigationmock backed by jsdom's real URL and history, so tests see pushState, back and forward.?tab=values indocumentation/settings-pages.md; the new e2e spec indocumentation/testing/e2e-harness.md.Tests
tests/app/admin-settings.page.test.tsx, 6 new: the address opens its tab;authin Plex mode and an unknown tab fall back to the first tab without rewriting the address or adding history; a click writes?tab=paths(the first tab as no parameter, and clicking the open tab adds no entry); back and forward move between tabs; unsaved edits survive a tab switch. 3 of them fail on main (the other 3 guard behaviour main already has)./admin/settings.e2e/specs/regressions/517-settings-tab-url.spec.tson the built image: deep link, reload, click (no RSC or document request), back, forward, unknown tab.Screenshots
Opened at
/admin/settings?tab=paths:After clicking Download Client (the address becomes
?tab=download):Checks
npx vitest related --runon the changed files: 22/22npx tsc --noEmit: cleannpx eslinton the changed files: no new findings (the same 18 as main, all in untouched lines)Risk and rollback
Small and contained to the Settings page. The one behaviour change beyond the address is a history entry per tab click, which is what makes back and forward work. Rollback is a revert of this commit; nothing is stored, so there is nothing to clean up.
Based on #517 by @NichCodes.
🤖 Generated with Claude Code