docs(nav): restoreNavPosition's doc back on restoreNavPosition

This commit is contained in:
2026-09-19 05:54:19 +02:00
parent a7891d03c5
commit ce30b99327
+11 -8
View File
@@ -358,14 +358,9 @@ export function navPosition(): NavPosition | null {
const RESTORE_MS = 2000;
const RESTORE_POLL_MS = 50;
/** Focus the item at `pos` once its list is on screen again. A NAMED list (a rail) is found by its
* name: a rail that appeared above it in the meantime — "Continue watching", filled by the very title
* watched in between, after the page's cache expired — shifts every place after it, and matching by
* place landed the focus in the wrong rail (deep-review E11 round 2). An unnamed list only by its
* place, and only once the page has exactly as many lists as when it was left: with more or fewer,
* list N may be another list, and <body> is the honest outcome. Gives up when the time is up, and at
* once when focus is already somewhere (the reader moved on, a dialog took it). The item is focused
* where the scroll restore put it, never scrolled to. Returns a cancel. */
/** The item in `list` to hand the focus back to: the saved place while it still holds the saved
* name, else the nearest item of that name (names repeat — a log console's identical request
* lines), else the saved place. */
function restoreTarget(list: NavList, pos: NavPosition): HTMLElement | null {
const at = itemAt(list, pos.index);
if (!pos.name || (at && itemName(at) === pos.name)) return at;
@@ -376,6 +371,14 @@ function restoreTarget(list: NavList, pos: NavPosition): HTMLElement | null {
return named[0] ?? at;
}
/** Focus the item at `pos` once its list is on screen again. A NAMED list (a rail) is found by its
* name: a rail that appeared above it in the meantime — "Continue watching", filled by the very title
* watched in between, after the page's cache expired — shifts every place after it, and matching by
* place landed the focus in the wrong rail (deep-review E11 round 2). An unnamed list only by its
* place, and only once the page has exactly as many lists as when it was left: with more or fewer,
* list N may be another list, and <body> is the honest outcome. Gives up when the time is up, and at
* once when focus is already somewhere (the reader moved on, a dialog took it). The item is focused
* where the scroll restore put it, never scrolled to. Returns a cancel. */
export function restoreNavPosition(pos: NavPosition): () => void {
const deadline = Date.now() + RESTORE_MS;
let timer: ReturnType<typeof setTimeout> | undefined;