neherlab / covid19_scenarios

Models of COVID-19 outbreak trajectories and hospital demand
https://covid19-scenarios.org
MIT License
1.36k stars 352 forks source link

Scrolling position is remembered incorrectly after page reload #142

Closed ivan-aksamentov closed 4 years ago

ivan-aksamentov commented 4 years ago

🐛 Bug Report

I don't have the exact steps yet. It is especially noticeable on a narrow device. Also when dev tools are open wide and the viewport is narrower and can be scrolled.

🤔 Expected Behavior

Remembered scrolling position is reset after page reload, preferably. Otherwise, maybe at least reset after I scroll to the top? Lack of memory whatsoever would also be fine. We don't need fancy.

😯 Current Behavior

Scroll position is being retained needlessly and unexpectedly. Also wrongly (the position is not the same as)

After scrolling and then refreshing the page (F5, Ctrl+F5) the browser scrolls to some place, not necessarily where I scrolled previously. After scrolling to the top page and refreshing it is still scrolling somewhere.

💁 Possible Solution

Suspected offender PRs: https://github.com/neherlab/covid19_scenarios/pull/84 https://github.com/neherlab/covid19_scenarios/pull/103

🔦 Context

💻 Code Sample

🌍 Your Environment

Software Version(s)
Browser
Operating System
NPM/Node/Yarn
rneher commented 4 years ago

this behavior goes away if the condition here

https://github.com/neherlab/covid19_scenarios/blob/master/src/components/Main/Main.tsx#L129

evaluates to false.

ivan-aksamentov commented 4 years ago

Fixed in #179