Consolidate method of reseting scroll position
## Issues (1) 4783: New search query does not reset to the top (2) The current way that Tag Search resets the position can be overridden by the AppRouter's call. ## Approach Listen to `search` changes as well. This basically covers any search param changes. Components should probably not call `window.scrollTo` directly as the AppRouter's call might override it.
This commit is contained in:
parent
a23b3c8d26
commit
4b53d1267c
2 changed files with 2 additions and 3 deletions
|
@ -347,8 +347,7 @@ function ClaimListDiscover(props: Props) {
|
|||
setPrevOptions(options);
|
||||
|
||||
if (didNavigateForward) {
|
||||
// --- Reset to top.
|
||||
window.scrollTo(0, 0); // Prevents onScrollBottom() from re-hitting while waiting for doClaimQuery():
|
||||
// --- Reset the page.
|
||||
options.page = 1;
|
||||
setPage(options.page);
|
||||
} else if (claimSearchResult) {
|
||||
|
|
|
@ -179,7 +179,7 @@ function AppRouter(props: Props) {
|
|||
if (!hasLinkedCommentInUrl) {
|
||||
window.scrollTo(0, currentScroll);
|
||||
}
|
||||
}, [currentScroll, pathname, resetScroll, hasLinkedCommentInUrl]);
|
||||
}, [currentScroll, pathname, search, resetScroll, hasLinkedCommentInUrl]);
|
||||
|
||||
// react-router doesn't decode pathanmes before doing the route matching check
|
||||
// We have to redirect here because if we redirect on the server, it might get encoded again
|
||||
|
|
Loading…
Add table
Reference in a new issue