explodorama / commit
What's new dialog: Back keeps the scroll position (0.2.0 work)
src/ui/whatsnew.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ui/whatsnew.ts b/src/ui/whatsnew.ts index da8b731..636c7ba 100644 --- a/src/ui/whatsnew.ts +++ b/src/ui/whatsnew.ts @@ -125,16 +125,29 @@ export function openChanges(releases: Release[] = RELEASES, intro = false): void let shown = { releases: RELEASES, intro: false } -/** A change's own dialog, its clip above what it does; Back returns to the list (from its top). */ +/** A change's own dialog, its clip above what it does; Back returns to the list, scrolled to where it was (user request, 2026-11-01). */ function openChange(button: HTMLElement): void { const { changeClip, sprite, name } = button.dataset const text = [...button.querySelectorAll('p')].map((p) => p.outerHTML).join('') const back = shown + const body = document.getElementById('dialog-body')! + const scrolled = body.scrollTop openDialog({ icon: spriteUrl(sprite!), title: name!, body: '<canvas class="clip" aria-hidden="true"></canvas>' + text, - buttons: [{ label: 'Back', kind: 'plain', onClick: () => openChanges(back.releases, back.intro) }], + buttons: [ + { + label: 'Back', + kind: 'plain', + onClick: () => { + openChanges(back.releases, back.intro) + body.scrollTop = scrolled + // Once laid out, if the dialog wasn't yet. + requestAnimationFrame(() => (body.scrollTop = scrolled)) + }, + }, + ], }) startClip(document.querySelector<HTMLCanvasElement>('#dialog-body canvas.clip')!, changeClip as SceneKind) }