WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 34d6f86

Browse files
committed
Fix url params being lost when making a selection after loading a diff
from the dialog
1 parent cf4b208 commit 34d6f86

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

web/src/lib/diff-viewer.svelte.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { ProgressBarState } from "$lib/components/progress-bar/index.svelte";
2929
import { Keybinds } from "./keybinds.svelte";
3030
import { LayoutState, type PersistentLayoutState } from "./layout.svelte";
3131
import { page } from "$app/state";
32-
import { afterNavigate, goto, pushState, replaceState } from "$app/navigation";
32+
import { afterNavigate, goto, replaceState } from "$app/navigation";
3333
import { type AfterNavigate } from "@sveltejs/kit";
3434

3535
export const GITHUB_URL_PARAM = "github_url";
@@ -694,7 +694,12 @@ export class MultiFileDiffViewerState {
694694
if (opts?.state === "replace") {
695695
replaceState(link, this.createPageState({ initialLoad: true }));
696696
} else {
697-
pushState(link, this.createPageState({ initialLoad: true }));
697+
// We must use goto instead of replaceState, otherwise page.url will not be updated.
698+
// This is fine for loadPatches, but may be heavy handed in other cases. Do not blindly copy this strategy.
699+
// https://github.com/sveltejs/kit/issues/13569
700+
await goto(link, {
701+
state: this.createPageState({ initialLoad: true }),
702+
});
698703
}
699704

700705
return true;

0 commit comments

Comments
 (0)