Skip to content

Commit 1791d65

Browse files
committed
Fix GlobalErrorBoundary navigation not working after error
- Add LocationChanged handler to auto-clear error state on navigation - Call Recover() before navigating in NavigateHome() - Fix dashboard URL from /app to / (correct route) - Implement IDisposable to clean up event handler
1 parent 6379a41 commit 1791d65

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

cloud/src/LrmCloud.Web/Components/GlobalErrorBoundary.razor

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@* Global error boundary component - catches and displays unhandled errors gracefully *@
22
@inherits ErrorBoundary
3+
@implements IDisposable
34
@inject NotificationService NotificationService
45
@inject ILogger<GlobalErrorBoundary> Logger
56

@@ -60,12 +61,22 @@ else
6061
[Inject]
6162
private NavigationManager Navigation { get; set; } = null!;
6263

63-
#if DEBUG
6464
protected override void OnInitialized()
6565
{
66+
Navigation.LocationChanged += OnLocationChanged;
67+
#if DEBUG
6668
ShowDetails = true;
67-
}
6869
#endif
70+
}
71+
72+
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
73+
{
74+
if (CurrentException != null)
75+
{
76+
Recover();
77+
StateHasChanged();
78+
}
79+
}
6980

7081
protected override Task OnErrorAsync(Exception exception)
7182
{
@@ -76,6 +87,12 @@ else
7687

7788
private void NavigateHome()
7889
{
79-
Navigation.NavigateTo("/app");
90+
Recover();
91+
Navigation.NavigateTo("");
92+
}
93+
94+
public void Dispose()
95+
{
96+
Navigation.LocationChanged -= OnLocationChanged;
8097
}
8198
}

0 commit comments

Comments
 (0)