Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Dispose fluent toolbar module properly
  • Loading branch information
Adam Ratzman committed Mar 4, 2025
commit 45c002993f8bfd8561062a995e74704244cf3106
17 changes: 13 additions & 4 deletions src/Core/Components/Toolbar/FluentToolbar.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public partial class FluentToolbar : FluentComponentBase, IAsyncDisposable
private IJSRuntime JSRuntime { get; set; } = default!;

/// <summary />
private IJSObjectReference Module { get; set; } = default!;
private IJSObjectReference? Module { get; set; }

/// <summary>
/// Gets or sets the toolbar's orentation. See <see cref="Orientation"/>
Expand Down Expand Up @@ -57,10 +57,19 @@ protected override async Task OnAfterRenderAsync(bool firstRender)

public async ValueTask DisposeAsync()
{
if (Module is not null && !string.IsNullOrEmpty(Id))
try
{
await Module.InvokeVoidAsync("removePreventArrowKeyNavigation", Id);
await Module.DisposeAsync();
if (Module is not null && !string.IsNullOrEmpty(Id))
{
await Module.InvokeVoidAsync("removePreventArrowKeyNavigation", Id);
await Module.DisposeAsync();
}
}
catch (Exception ex) when (ex is JSDisconnectedException ||
ex is OperationCanceledException)
{
// The JSRuntime side may routinely be gone already if the reason we're disposing is that
// the client disconnected. This is not an error.
}
}
}
Loading