Skip to content

Commit eb69408

Browse files
fix: scroll left sidebar to 'now' indicator on initial load (#2888)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: john@hyprnote.com <john@hyprnote.com>
1 parent 615b53a commit eb69408

File tree

1 file changed

+4
-4
lines changed
  • apps/desktop/src/components/main/sidebar/timeline

1 file changed

+4
-4
lines changed

apps/desktop/src/components/main/sidebar/timeline/anchor.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,19 @@ export function useAutoScrollToAnchor({
8484
anchorNode: HTMLDivElement | null;
8585
deps?: DependencyList;
8686
}) {
87-
const hasMountedRef = useRef(false);
87+
const hasInitialScrolledRef = useRef(false);
8888
const prevAnchorNodeRef = useRef<HTMLDivElement | null>(null);
8989

9090
useEffect(() => {
91-
if (hasMountedRef.current) {
91+
if (!anchorNode || hasInitialScrolledRef.current) {
9292
return;
9393
}
94-
hasMountedRef.current = true;
9594

95+
hasInitialScrolledRef.current = true;
9696
requestAnimationFrame(() => {
9797
scrollFn();
9898
});
99-
}, [scrollFn]);
99+
}, [anchorNode, scrollFn]);
100100

101101
useEffect(() => {
102102
if (!anchorNode || prevAnchorNodeRef.current === anchorNode) {

0 commit comments

Comments
 (0)