Skip to content

Commit fc6dbe9

Browse files
authored
fix(code-review): retain explicit jump selection
Generated-By: PostHog Code Task-Id: 71e782ac-16eb-409f-a5d3-2aa4ad9117f8
1 parent 24e63b5 commit fc6dbe9

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

packages/ui/src/features/code-review/components/ReviewShell.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function ReviewShell({
128128
const taskId = task.id;
129129
const listRef = useRef<VListHandle | null>(null);
130130
const lastActiveRef = useRef<string | null>(null);
131-
const navigationLockUntilRef = useRef(0);
131+
const navigationLockedRef = useRef(false);
132132

133133
const workerFactory = useCallback(
134134
() => reviewHost.diffWorkerFactory(),
@@ -217,7 +217,7 @@ export function ReviewShell({
217217
const viewed =
218218
currentSignature !== undefined &&
219219
isFileViewed(viewedRecord[scrollRequest], currentSignature);
220-
navigationLockUntilRef.current = Date.now() + 500;
220+
navigationLockedRef.current = true;
221221
if (!viewed) onUncollapseFile?.(scrollRequest);
222222
requestAnimationFrame(() => {
223223
listRef.current?.scrollToIndex(targetIndex, { align: "start" });
@@ -238,8 +238,7 @@ export function ReviewShell({
238238

239239
const handleScroll = useCallback(
240240
(offset: number) => {
241-
if (Date.now() < navigationLockUntilRef.current) return;
242-
navigationLockUntilRef.current = 0;
241+
if (navigationLockedRef.current) return;
243242
const handle = listRef.current;
244243
if (!handle) return;
245244
const index = handle.findItemIndex(offset);
@@ -253,7 +252,7 @@ export function ReviewShell({
253252
);
254253

255254
const handleUserScrollIntent = useCallback(() => {
256-
navigationLockUntilRef.current = 0;
255+
navigationLockedRef.current = false;
257256
}, []);
258257

259258
const renderItem = useCallback(
@@ -314,7 +313,13 @@ export function ReviewShell({
314313
defaultBranch={defaultBranch}
315314
/>
316315
<Flex className="min-h-0 flex-1">
317-
<Flex direction="column" className="min-w-0 flex-1">
316+
<Flex
317+
direction="column"
318+
className="min-w-0 flex-1"
319+
onPointerDownCapture={handleUserScrollIntent}
320+
onWheelCapture={handleUserScrollIntent}
321+
onKeyDownCapture={handleUserScrollIntent}
322+
>
318323
{isLoading ? (
319324
<Flex
320325
align="center"
@@ -342,8 +347,6 @@ export function ReviewShell({
342347
shift={false}
343348
style={{ scrollbarGutter: "stable" }}
344349
onScroll={handleScroll}
345-
onWheel={handleUserScrollIntent}
346-
onKeyDown={handleUserScrollIntent}
347350
data={items}
348351
>
349352
{renderItem}

0 commit comments

Comments
 (0)