Scroll position not preserved after clicking "Show more" on a filtered connection list
Created by: courier-new
- Sourcegraph version: Sourcegraph.com
- Platform information: Most major browsers (Chrome, Firefox, Safari, Brave tested)
This is easiest to reproduce with the Batch Changes list view but happens anywhere there's a filtered connection with more results than are initially displayed.
Steps to reproduce:
- Visit https://k8s.sgdev.org/batch-changes (signed in to an account in the Sourcegraph org)
- Scroll the list to the bottom and click "Show more"
- Wait for query to complete
Expected behavior:
URL updates with new ?visible=30
parameter and scroll position on the page does not change.
Actual behavior:
URL updates with new ?visible=30
parameter and scroll position is reset to the top of the page.
I believe this is an unintended consequence of https://github.com/sourcegraph/sourcegraph/pull/29178. Since react-scroll-manager caches scroll position against the path, when the filtered connection components change the URL parameter with history.replace
, the resultant path is not found in the cache. Since there's no scroll position associated with it, then, it defaults to 0, 0 instead, causing the unexpected jump.
The problematic behavior ceases if either:
-
FilteredConnection.useURLQuery
(orUseConnectionConfig.useURL
for the new hook variation) is set tofalse
-
ScrollManager
is removed from the root rendering tree ofSourcegraphWebApp
The ideal solution would be to instruct react-scroll-manager to ignore the URL parameter when caching scroll position on routes with filtered connections where changing the parameter does not change what page the user is on.
Here is a screen recording of behavior. Pay attention to the URL when the scroll jump happens (they correspond).
https://user-images.githubusercontent.com/8942601/157168698-509aaf53-d962-40e7-a30a-9eff234cb5d9.mov