From 04c2dcfc6b78c7e8714597f9d5370b6b2c87dece Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Jun 2022 14:36:24 +0200 Subject: [PATCH] Fix login form scrolling --- client/src/app/core/routing/scroll.service.ts | 2 +- .../src/app/shared/shared-main/angular/autofocus.directive.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/src/app/core/routing/scroll.service.ts b/client/src/app/core/routing/scroll.service.ts index bd5076502..6d37fde71 100644 --- a/client/src/app/core/routing/scroll.service.ts +++ b/client/src/app/core/routing/scroll.service.ts @@ -67,7 +67,7 @@ export class ScrollService { private consumeScroll () { // Handle anchors/restore position this.peertubeRouter.getScrollEvents().subscribe(e => { - logger('Will schedule scroll after router event %o.', e) + logger('Will schedule scroll after router event %o.', { e, resetScroll: this.resetScroll }) // scrollToAnchor first to preserve anchor position when using history navigation if (e.anchor) { diff --git a/client/src/app/shared/shared-main/angular/autofocus.directive.ts b/client/src/app/shared/shared-main/angular/autofocus.directive.ts index 2da492ea1..051635f45 100644 --- a/client/src/app/shared/shared-main/angular/autofocus.directive.ts +++ b/client/src/app/shared/shared-main/angular/autofocus.directive.ts @@ -7,6 +7,8 @@ export class AutofocusDirective implements AfterViewInit { constructor (private host: ElementRef) { } ngAfterViewInit () { - this.host.nativeElement.focus() + const el = this.host.nativeElement as HTMLElement + + el.focus({ preventScroll: true }) } } -- 2.41.0