-
-
Notifications
You must be signed in to change notification settings - Fork 80
Restore scroll-to-top on route navigation with proper cleanup #1556
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
Conversation
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Initial plan * Remove commented-out border-right style from print.css Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com>
* Initial plan * Remove empty CSS rule blocks from print.css Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com>
* Initial plan * Add conditional guards for tag iterations in projectItems and talkItems sections Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com> Co-authored-by: Sebastian Schreck <StegSchreck@users.noreply.github.com>
* Initial plan * Fix data loading issue - ensure title and meta are set after generalData is populated Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…onality Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com>
Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com>
Co-authored-by: StegSchreck <9078002+StegSchreck@users.noreply.github.com>
|
Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
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.
Pull request overview
This PR restores the scroll-to-top functionality when navigating between CV sections, which was previously removed in commit f4b446f. The implementation adds manual router event subscription with proper lifecycle management.
- Restored router subscription to trigger
window.scrollTo(0, 0)on NavigationEnd events - Implemented OnDestroy lifecycle hook with cleanup for both router and language service subscriptions
- Fixed TypeScript interface placement by moving GeneralData interface before the @component decorator
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/app/app.component.ts | Adds router subscription for scroll-to-top behavior, implements OnDestroy for subscription cleanup, and fixes interface placement issue |
| .gitignore | Excludes package-lock.json to prevent conflicts with Yarn-based dependency management |
| ngOnDestroy() { | ||
| this.routerSubscription?.unsubscribe(); | ||
| this.languageSubscription?.unsubscribe(); | ||
| } |
Copilot
AI
Jan 1, 2026
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.
The ngOnDestroy lifecycle hook is unlikely to be called for the root AppComponent in a typical Angular application. The root component is only destroyed when the entire application shuts down (e.g., closing the browser tab), at which point all resources are automatically released by the browser. While implementing ngOnDestroy shows good practice for subscription cleanup, the unsubscribe calls here will effectively never execute in production.
For the root component, subscription cleanup is not critical since the subscriptions will live for the application's entire lifetime. However, if this pattern is intended to be educational or for consistency, it's acceptable to keep.
| // Scroll to top on route navigation | ||
| this.routerSubscription = this.router.events | ||
| .pipe(filter(event => event instanceof NavigationEnd)) | ||
| .subscribe(() => { | ||
| window.scrollTo(0, 0); | ||
| }); |
Copilot
AI
Jan 1, 2026
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.
Consider using Angular Router's built-in scroll restoration feature instead of manually subscribing to router events. You can configure this in the RouterModule by adding the scrollPositionRestoration option:
In app-routing.module.ts, modify the RouterModule.forRoot() call:
RouterModule.forRoot(routes, {
preloadingStrategy: PreloadAllModules,
scrollPositionRestoration: 'top'
})
This approach is more declarative, doesn't require subscription management, and is the recommended Angular way to handle scroll-to-top behavior on navigation. It would eliminate the need for the router subscription in the constructor and the routerSubscription property.
Router navigation event subscription was removed in commit f4b446f, breaking automatic scroll-to-top behavior when navigating between CV sections.
Changes
router.eventssubscription filtered byNavigationEndto callwindow.scrollTo(0, 0)on route changesOnDestroyto unsubscribe from both router and languageChanged subscriptions, preventing memory leaksGeneralDatainterface definition before@Componentdecorator to resolve TypeScript compilation errors✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.