This PR addresses a long-standing issue where, on mobile devices in production, if you visit a politician's page, scroll down, then navigate back and to a different politician's page, the scroll position from the previous page is unexpectedly carried over to the new page. This requires the user to manually scroll back to the top.
I've tested various approaches to fix this, including enabling and disabling scroll behavior on router.push, but this didn’t resolve the issue. I also tried adding an ID to the politician photo section and appending it to the router's pathname, but that approach didn't work either. Given that all politician page components are server-side rendered and useEffect can’t be used to handle scrolling, I created a new component that ensures the page scrolls to the top upon render. This solution can also be reused in other server-side components.
closes #814
What changed? Why?
This PR addresses a long-standing issue where, on mobile devices in production, if you visit a politician's page, scroll down, then navigate back and to a different politician's page, the scroll position from the previous page is unexpectedly carried over to the new page. This requires the user to manually scroll back to the top.
I've tested various approaches to fix this, including enabling and disabling scroll behavior on router.push, but this didn’t resolve the issue. I also tried adding an ID to the politician photo section and appending it to the router's pathname, but that approach didn't work either. Given that all politician page components are server-side rendered and useEffect can’t be used to handle scrolling, I created a new component that ensures the page scrolls to the top upon render. This solution can also be reused in other server-side components.
How has it been tested?
Before the fix
https://github.com/user-attachments/assets/d6b55c44-1638-4947-9447-a03e6998586c
After the fix
https://github.com/user-attachments/assets/125f142c-4637-43ad-8ee2-8cfb5bba5ec8