Clarify browser behaviour

Open
#8 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale

Research direction

Read the existing documentation alongside the linked HTML specification sections and both CodePen examples. Clarify that browsers can restore nested scroll containers, while restoration may fail when the element is removed and later remounted; confirm the final wording against the examples.

Written by the indexing model from the issue text.

Description

help wanted

Hey! 👋 I just wanted to drop a note about something in the documentation that I think is incorrect:

If the user scrolls a list, then navigates back and forth, the browser will scroll the page to the top, but the list will still be scrolled to the position it was at when the user left the page.

Browsers can actually restore scroll positions for nested scroll containers. Here's a reduced test case to demonstrate that scroll restoration does work for non-body aka nested scroll containers: https://codepen.io/OliverJAsh/pen/bGPqyRw

Relevant specs:

I think the issue you're referring to is what happens when an element is removed from the DOM after leaving one page and then restored when navigating back. In this case, the browser can't restore scroll because it has no way of knowing that we're remounting the same element as before. Reduced test case: https://codepen.io/OliverJAsh/pen/gONmJZM

Perhaps we could clarify this in the documentation? Or perhaps I've misunderstood 😄

Dominant language
TypeScript
Stars
261
Forks
6
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from epicweb-dev/restore-scroll

All issues in epicweb-dev/restore-scroll

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.