]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-settings/my-account-settings.component.ts
Fix scrolling with hash in url
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-settings / my-account-settings.component.ts
index 5f2db985487dc873f0aff6fb824d6a909d708542..f73f3aa1e09de556fc9812d803dfe0c0df596f6d 100644 (file)
@@ -23,6 +23,8 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
   userVideoQuotaUsedDaily = 0
   userVideoQuotaDailyPercentage = 15
 
+  private lastScrollHash: string
+
   constructor (
     private viewportScroller: ViewportScroller,
     private userService: UserService,
@@ -64,7 +66,11 @@ export class MyAccountSettingsComponent implements OnInit, AfterViewChecked {
   }
 
   ngAfterViewChecked () {
-    if (window.location.hash) this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
+    if (window.location.hash && window.location.hash !== this.lastScrollHash) {
+      this.viewportScroller.scrollToAnchor(window.location.hash.replace('#', ''))
+
+      this.lastScrollHash = window.location.hash
+    }
   }
 
   onAvatarChange (formData: FormData) {