From 88e5142049bbf6322db274367b22e6779f2cd1b2 Mon Sep 17 00:00:00 2001 From: Leendert de Borst Date: Tue, 22 Oct 2024 21:18:26 +0200 Subject: [PATCH] Add scroll to top when switching between steps (#315) --- src/AliasVault.Client/Auth/Pages/Setup/Setup.razor | 5 ++++- src/AliasVault.Client/Services/JsInteropService.cs | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/AliasVault.Client/Auth/Pages/Setup/Setup.razor b/src/AliasVault.Client/Auth/Pages/Setup/Setup.razor index ec1e37f7c..d371cc9ac 100644 --- a/src/AliasVault.Client/Auth/Pages/Setup/Setup.razor +++ b/src/AliasVault.Client/Auth/Pages/Setup/Setup.razor @@ -135,7 +135,7 @@ /// /// Navigates to the next step in the setup process. /// - private void GoNext() + private async Task GoNext() { _currentStep = _currentStep switch { @@ -145,6 +145,9 @@ SetupStep.Password => SetupStep.Creating, _ => _currentStep }; + + await JsInteropService.ScrollToTop(); + StateHasChanged(); } /// diff --git a/src/AliasVault.Client/Services/JsInteropService.cs b/src/AliasVault.Client/Services/JsInteropService.cs index 272829a61..d32645134 100644 --- a/src/AliasVault.Client/Services/JsInteropService.cs +++ b/src/AliasVault.Client/Services/JsInteropService.cs @@ -228,6 +228,15 @@ public sealed class JsInteropService(IJSRuntime jsRuntime) } } + /// + /// Scrolls to the top of the page. + /// + /// Task. + public async Task ScrollToTop() + { + await jsRuntime.InvokeVoidAsync("window.scrollTo", 0, 0); + } + /// /// Represents the result of a WebAuthn get credential operation. ///