diff --git a/web/src/lib/components/repo/DiffCodeView.svelte b/web/src/lib/components/repo/DiffCodeView.svelte index c9bb3f5e7..91007c6d4 100644 --- a/web/src/lib/components/repo/DiffCodeView.svelte +++ b/web/src/lib/components/repo/DiffCodeView.svelte @@ -59,6 +59,7 @@ const LOOKAHEAD_ITEMS = 8; let root: HTMLElement | undefined = $state(); + let scroller: HTMLElement | undefined; let contentHeight = $state(0); let view: CodeView | undefined = $state.raw(); let initError = $state(); @@ -207,6 +208,7 @@ }); instance.setup(element); + scroller = element; instance.setItems(files.map(itemOf)); appliedStyle = untrack(() => diffStyle); appliedFiles = files; @@ -220,6 +222,7 @@ for (const id of [...headers.keys()]) dropHeader(id); view?.cleanUp(); view = undefined; + scroller = undefined; }; }); @@ -240,7 +243,7 @@ }; const syncScroll = () => { - const element = root; + const element = scroller; if (!element) return; const container = element.firstElementChild; if (container) { @@ -259,7 +262,7 @@ $effect(() => { const instance = view; - const element = root; + const element = scroller; if (!instance || !element) return; syncScroll(); const observer = new ResizeObserver(syncScroll);