diff --git a/web/src/header.ts b/web/src/header.ts index 0aa5bc0d..44042141 100644 --- a/web/src/header.ts +++ b/web/src/header.ts @@ -32,6 +32,14 @@ const restoreLibrarySelection = (): void => { if (dropdown) { const option = dropdown.querySelector(`option[value="${savedLibrary}"]`); if (option) { + // SSR pages already render the select with the stored library + // (setSelectedLibrary keeps the cookie in sync and resolveLibrary + // renders from it). Re-firing `change` here made every page load + // re-run the page's switch handler — which re-fetches content at + // hardcoded page 1 / offset 0 and stomps URL-tracked state (this + // broke the /series paginator: page 2 snapped back to page 1). + // Only re-fire when the select actually drifted from storage. + if (dropdown.value === savedLibrary) return; dropdown.value = savedLibrary; dropdown.dispatchEvent(new Event("change", { bubbles: true })); console.log("Restored library selection:", savedLibrary);