Skip to content

fix: Error on dispose in FluentMenu #4248

@JamesNK

Description

@JamesNK

🐛 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

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions