Skip to content

Commit b97f9cb

Browse files
ui: open the levels catalog scrolled to the first exercise
1 parent e1fbb13 commit b97f9cb

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎src/ui/app.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,13 @@ export class App {
839839
actions: [{ label: u.close, className: 'ghost', onClick: () => undefined }],
840840
});
841841

842+
// showModal focuses the footer button, which the browser scrolls into view —
843+
// the tall catalog would land at its bottom. Reset to the top so the first
844+
// exercise is what's visible.
845+
const panel = modal.el.querySelector<HTMLElement>('.modal');
846+
panel?.scrollTo({ top: 0 });
847+
requestAnimationFrame(() => panel?.scrollTo({ top: 0 }));
848+
842849
modal.el.querySelectorAll<HTMLButtonElement>('[data-level]').forEach((btn) => {
843850
btn.addEventListener('click', () => {
844851
const id = btn.dataset.level;

0 commit comments

Comments
 (0)