Skip to content

Commit 701f7aa

Browse files
authored
[HUD] Fix SLI page scroll reset and navigation hijacking (#6945)
Fix SLI page navigation and scroll issues This PR fixes two issues on the /sli page: 1. Scroll position was locked at the top of the page 2. Navigation hijacking: Clicking navbar links would briefly navigate away but then immediately return to /sli Changes: - Added shallow: true to router.push() to prevent full page re-renders when updating URL parameters - Added pathname check to prevent the useEffect from running when navigating away from the page
1 parent 20802cb commit 701f7aa

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

torchci/pages/sli.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ export default function Page() {
264264
useEffect(() => {
265265
if (!router.isReady) return;
266266

267+
// Only update URL if we're still on the SLI page
268+
if (router.pathname !== "/sli") return;
269+
267270
const params = new URLSearchParams();
268271

269272
if (timeRange !== -1) {
@@ -286,10 +289,14 @@ export default function Page() {
286289
params.set("ttsPercentile", initialTtsPercentile);
287290
}
288291

289-
router.push({
290-
pathname: router.pathname,
291-
query: params.toString(),
292-
});
292+
router.push(
293+
{
294+
pathname: router.pathname,
295+
query: params.toString(),
296+
},
297+
undefined,
298+
{ shallow: true }
299+
);
293300
}, [
294301
initialTtsPercentile,
295302
initialWorkerTypes,

0 commit comments

Comments
 (0)