Skip to content

fix: Error on dispose in FluentMenu#4248

Description

馃悰 Bug Report

I see this error when hot reloading:

fail: Aspire.Hosting.Dashboard.Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'rBZiMW0JBoyiB3tlk6cZbCzTCjG4stihwH9QbT2x3k4'.
      System.ArgumentNullException: Value cannot be null. (Parameter 'jsObjectReference')
         at System.ArgumentNullException.Throw(String paramName)
         at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
         at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(IJSObjectReference jsObjectReference, String identifier, Object[] args)
         at Microsoft.FluentUI.AspNetCore.Components.FluentMenu.DisposeAsync()

馃 Expected Behavior

No error

馃槸 Current Behavior

Error

馃拋 Possible Solution

Check whether these module references are null before using them:

await _jsModule.InvokeVoidAsync("dispose", Anchor);
await _jsModule.DisposeAsync();
await _anchoredRegionModule.DisposeAsync();

IMO the fields should be nullable so nullable checks catch this. Almost everywhere they're used in this type they're checked for null before use.

馃敠 Context

馃實 Your Environment

  • OS & Device: [e.g. MacOS, iOS, Windows, Linux] on [iPhone 7, PC]
  • Browser [e.g. Microsoft Edge, Google Chrome, Apple Safari, Mozilla FireFox]
  • .NET and Fluent UI Blazor library Version [e.g. 8.0.2 and 4.4.1]

Metadata

Metadata

Assignees

Labels

bugA bugclosed:doneWork is finished. The version in which the work will show up might not have been released yet!

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions