Skip to content

feat(shelf): restore scroll position after chapter quiz - #45

Merged
jsolly merged 3 commits into
mainfrom
cursor/shelf-scroll-restore-c8f0
Jul 19, 2026
Merged

feat(shelf): restore scroll position after chapter quiz#45
jsolly merged 3 commits into
mainfrom
cursor/shelf-scroll-restore-c8f0

Conversation

@jsolly

@jsolly jsolly commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • When a learner opens a chapter from a shelf, we save the shelf scrollY in sessionStorage (per unit).
  • Returning via Back to chapters (after a chapter quiz), Browse chapters, or ← Back to shelf restores that scroll position instead of jumping to the top.
  • Those chapter return actions now use in-app openShelf (with a chapter focus fallback) so restore is reliable without a full reload.
  • Shelf heading focus uses preventScroll; saved scroll is cleared only after a successful restore.

Test plan

  • Open a long shelf, scroll mid-way, open a chapter, quiz, Back to chapters → scroll restored
  • Scroll shelf mid-way → open chapter → scroll to bottom → Browse chapters → same shelf scroll restored
  • ← Back to shelf also restores scroll
  • Fresh visit to a shelf (from home) still starts at the top
  • Smoke desktop + mobile; console clean

Verification

Desktop + mobile: Browse chapters, Back to shelf, and Back to chapters all restore the pre-chapter shelf scroll; fresh home→shelf visits still start at the top.

Open in Web Open in Cursor 

cursoragent and others added 2 commits July 18, 2026 22:40
Save the shelf window scroll when opening a chapter, then restore it
when returning via Back to chapters (or Back to shelf). Heading focus
no longer jumps the viewport to the top.

Co-authored-by: John Solly <jsolly@users.noreply.github.com>
Route Browse chapters and Back to shelf through openShelf so the
saved shelf scroll is restored after reading a chapter. Harden restore
timing so early layout passes cannot clear the saved position too soon.

Co-authored-by: John Solly <jsolly@users.noreply.github.com>
@cursor
cursor Bot marked this pull request as ready for review July 18, 2026 23:02
Resolve ShelfView + constants conflicts: keep shelf scroll restore
alongside hide-read UI and summary headlines from main.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jsolly
jsolly merged commit 9b2c41c into main Jul 19, 2026
3 checks passed
@jsolly
jsolly deleted the cursor/shelf-scroll-restore-c8f0 branch July 19, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants