Skip to content

Commit 7d903f3

Browse files
committed
fix(files-page): use instant scroll-to-file to match hosted
Drop `behavior: "smooth"` from `window.scrollTo` so the scrollend fires immediately after a click, and revert the manual-selection suppress from 800ms back to 100ms — the longer window was a workaround for the smooth-scroll animation that's no longer needed.
1 parent 32d4709 commit 7d903f3

2 files changed

Lines changed: 2 additions & 8 deletions

File tree

packages/web/src/components/files/file-diff-list.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const FileDiffList = forwardRef<FileDiffListHandle, FileDiffListProps>(fu
3636
const el = document.getElementById(`file-${filePath}`);
3737
if (!el) return;
3838
const top = el.getBoundingClientRect().top + window.scrollY - STICKY_HEADER_OFFSET;
39-
window.scrollTo({ top, behavior: "smooth" });
39+
window.scrollTo({ top });
4040
},
4141
}),
4242
[],

packages/web/src/lib/use-active-file-on-scroll.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@ import { useCallback, useEffect, useRef, useState } from "react";
22
import type { PullRequestFile } from "./diff-types";
33

44
const HEADER_OFFSET = 96;
5-
// Generous enough to outlast browser-defined smooth-scroll animations
6-
// (typically 300–500ms) so the scrollend that fires when the click-driven
7-
// scroll settles can't override the user's manual selection.
8-
const MANUAL_SELECTION_SUPPRESS_MS = 800;
95

106
export function useActiveFileOnScroll(files: PullRequestFile[]) {
117
const [activeFilePath, setActiveFilePath] = useState<string | undefined>();
128
const suppressUntilRef = useRef(0);
139

1410
const setActiveFileManually = useCallback((path: string) => {
1511
setActiveFilePath(path);
16-
// Suppress the next scrollend so a click-driven smooth scroll doesn't
17-
// re-pick a different file when its animation settles.
18-
suppressUntilRef.current = Date.now() + MANUAL_SELECTION_SUPPRESS_MS;
12+
suppressUntilRef.current = Date.now() + 100;
1913
}, []);
2014

2115
useEffect(() => {

0 commit comments

Comments
 (0)