commit 03934f069858f90ed1c50c1001efbc30abceb3e6
parent bbdf09401aaea32a124833e30fbb3f3a7fc24168
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Thu, 29 Oct 2026 05:06:52 -0400
editor: /changelog scrolls to a deep link's heading once the streamed notes are in
The notes stream in after the shell, moved into place by React's streaming
script, so the browser's own scroll to #anchor could fire while the heading
was still in the hidden holding node and leave the page at the top (the e2e
run caught /changelog#2024-01-01 landing on ?page=3 unscrolled). ScrollToHash,
rendered at the end of the notes, scrolls to the hash's element once they are
in the document, unless it is already in view.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/editor/app/changelog/ChangelogAnchorResolver.tsx b/editor/app/changelog/ChangelogAnchorResolver.tsx
@@ -37,3 +37,28 @@ export function ChangelogAnchorResolver({
}, [anchors, page]);
return null;
}
+
+// THE SCROLL A STREAMED PAGE MISSES. The notes arrive after the shell, moved
+// into place by React's streaming script, so the browser's own scroll to
+// `#anchor` can fire while the heading is still in a hidden holding node and
+// leave the page at the top. Rendered at the END of the notes, this mounts
+// once they are in the document, and scrolls to the hash's element if it is
+// not already in view.
+export function ScrollToHash() {
+ useEffect(() => {
+ let id: string;
+ try {
+ id = decodeURIComponent(window.location.hash.slice(1));
+ } catch {
+ return;
+ }
+ if (!id) return;
+ const el = document.getElementById(id);
+ if (!el) return;
+ const box = el.getBoundingClientRect();
+ if (box.top >= 0 && box.bottom <= window.innerHeight && box.height > 0) return;
+ // An empty `v<version>` marker has no box of its own; its heading does.
+ (box.height > 0 ? el : (el.parentElement ?? el)).scrollIntoView({ block: "start" });
+ }, []);
+ return null;
+}
diff --git a/editor/app/changelog/ChangelogNotes.tsx b/editor/app/changelog/ChangelogNotes.tsx
@@ -2,6 +2,7 @@ import { readFile } from "node:fs/promises";
import Link from "next/link";
import { getPaths } from "yt-dlp-transcript-common/lib/paths";
import { Changelog } from "yt-dlp-transcript-common/components/Changelog";
+import { ScrollToHash } from "./ChangelogAnchorResolver";
import {
clampChangelogPage,
paginateChangelog,
@@ -90,6 +91,7 @@ export async function ChangelogNotes({
{nav}
<Changelog source={slice} />
{nav}
+ <ScrollToHash />
</section>
);
}