diff --git a/app/components/ConditionalScrollRestoration.tsx b/app/components/ConditionalScrollRestoration.tsx
new file mode 100644
index 000000000..5f630c000
--- /dev/null
+++ b/app/components/ConditionalScrollRestoration.tsx
@@ -0,0 +1,16 @@
+// temporary workaround before Remix has React Router 6.4
+// https://github.com/remix-run/remix/issues/186#issuecomment-1178395835
+
+import { ScrollRestoration, useLocation } from "@remix-run/react";
+
+export function ConditionalScrollRestoration() {
+ const location = useLocation();
+ if (
+ location.state != null &&
+ typeof location.state === "object" &&
+ (location.state as { scroll: boolean }).scroll === false
+ ) {
+ return null;
+ }
+ return ;
+}
diff --git a/app/modules/analyzer/useAnalyzeBuild.ts b/app/modules/analyzer/useAnalyzeBuild.ts
index dce5892ed..593653042 100644
--- a/app/modules/analyzer/useAnalyzeBuild.ts
+++ b/app/modules/analyzer/useAnalyzeBuild.ts
@@ -40,12 +40,15 @@ export function useAnalyzeBuild() {
newLdeIntensity?: number;
newEffects?: Array;
}) => {
- setSearchParams({
- weapon: String(newMainWeaponId),
- build: serializeBuild(newBuild),
- lde: String(newLdeIntensity),
- effect: newEffects,
- });
+ setSearchParams(
+ {
+ weapon: String(newMainWeaponId),
+ build: serializeBuild(newBuild),
+ lde: String(newLdeIntensity),
+ effect: newEffects,
+ },
+ { replace: true, state: { scroll: false } }
+ );
};
const buildsAbilityPoints = buildToAbilityPoints(build);
diff --git a/app/root.tsx b/app/root.tsx
index 61d764c39..e3cf27bd1 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -10,7 +10,6 @@ import {
Meta,
Outlet,
Scripts,
- ScrollRestoration,
useLoaderData,
type ShouldReloadFunction,
} from "@remix-run/react";
@@ -32,6 +31,7 @@ import { useTranslation } from "react-i18next";
import { Theme, ThemeHead, useTheme, ThemeProvider } from "./modules/theme";
import { getThemeSession } from "./modules/theme/session.server";
import { COMMON_PREVIEW_IMAGE } from "./utils/urls";
+import { ConditionalScrollRestoration } from "./components/ConditionalScrollRestoration";
export const unstable_shouldReload: ShouldReloadFunction = () => false;
@@ -112,7 +112,7 @@ function Document({
{children}
-
+