diff --git a/src/lib/core/LocationLite.svelte.ts b/src/lib/core/LocationLite.svelte.ts index c7e3fc3..67436b8 100644 --- a/src/lib/core/LocationLite.svelte.ts +++ b/src/lib/core/LocationLite.svelte.ts @@ -44,7 +44,11 @@ export class LocationLite implements Location { ['popstate', 'hashchange'].forEach((event) => { cleanups.push(on(globalThis.window, event, () => { this.#innerState.url.href = globalThis.window?.location?.href; - this.#innerState.state = globalThis.window?.history?.state; + if (!globalThis.window?.history?.state) { + // Potential hash navigation. Preserve current state. + this.#goTo(this.#innerState.url.href, true, this.#innerState.state); + } + this.#innerState.state = globalThis.window?.history?.state ?? this.#innerState.state; })); }); return () => {