-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(openchallenges): customize scroll position restoration with different navigation types #2189
Conversation
Some attempts using custom directive to prevent scroll position from being reset to 'top' is unsuccessful. When navigate back from Looking for other options... |
UpdateIt looks like Results:
The scroll position-y is not changed to 200 in all three lifecycle hooks until Update 2using |
I initially use Looking for options to store the previous url before navigation... Update
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an elegant solution. I need to confirm that the use of window
will not break SSR before approving this PR.
apps/openchallenges/app/src/app/custom-scroll-restoration.service.ts
Outdated
Show resolved
Hide resolved
I will explore the simpler solution @tschaffter suggested and convert this pr to draft. |
Closing this - the new approach to address the issue is tracked in #2273 |
Changelogs
Add a service to enable custom scroll position restoration. The built-in
scrollPositionRestoration
seems not to support the navigations when only parameters change. For example, in thesearch
pages, the scroll position is always reset to "top" when filter values changes (ifscrollPositionRestoration: 'top'
. Therefore, adding a custom service could overwrite default scroll reset behavior and restore the previous position depending on different navigations:Preview
Backward navigation
Forward navigation
Same url navigation
Param navigation