diff --git a/ServerManagement/Components/Pages/EditServer.razor b/ServerManagement/Components/Pages/EditServer.razor index 53821a3..ed4e72b 100644 --- a/ServerManagement/Components/Pages/EditServer.razor +++ b/ServerManagement/Components/Pages/EditServer.razor @@ -1,9 +1,17 @@ @page "/servers/{id:int}" @* Route constraints: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-9.0#route-constraints *@ -@attribute [ExcludeFromInteractiveRouting] +@* Note that this attribute now needs to be removed, because Routing is globally interactive. +The navigation manager only will respond correctly if all its behaviours are the same. *@ +@* @attribute [ExcludeFromInteractiveRouting] *@ @inject NavigationManager NavigationManager +@inject IJSRuntime JSRuntime + + +

Edit server


@@ -68,4 +76,13 @@ // An exception is raised when debugging from VS Code, but not when using dotnet watch. NavigationManager.NavigateTo("/servers"); } + + private async Task OnBeforeInternalNavigation(LocationChangingContext context) + { + var isConfirmed = await JSRuntime.InvokeAsync("confirm", "Are you sure you want to leave this page?"); + if (!isConfirmed) + { + context.PreventNavigation(); + } + } } \ No newline at end of file