I’ve been building a Blazor WebAssembly (WASM) app since DOTNET 6 (note: I do not have a Server Side head in this app), and after the most recent update, I can no longer get dialogs to show. All of this code used to work, and no changes have been made other than to accommodate the breaking changes for MudBlazor 7.
In my MainLayout.razor, I have the following.
<MudThemeProvider IsDarkMode="@_isDarkMode" Theme="_theme"/>
<MudPopoverProvider/>
<MudDialogProvider/>
<MudSnackbarProvider/>
And then in my ViewModel
public sealed class EditProductViewModel
{
public EditProductViewModel(IDialogService dialogService)
{
_dialogService = dialogService.ThrowIfNull();
// sets up the public API surface to use an Rx Interaction layer
_getThingInteraction.RegisterHandler(GetThingFromDialog);
}
public async Task AddThing(ProductFormat productFormat)
{
using var _ = _logger.AutoLogInOut();
var result = await _getThingInteraction.Handle(Unit.Default);
if (result != null)
{
productFormat.ThingDetails.AddThing(result);
StateChanged();
}
}
private async Task GetThingFromDialog(IInteractionContext<Unit, Thing> context)
{
using var _ = _logger.LogTraceInOut();
var parameters = new DialogParameters
{
[nameof(SelectThingDialog.Things)] = ThingDropDown
};
var dialog = await _dialogService.ShowAsync<SelectThingDialog>("Select a thing", parameters);
var result = await dialog.Result;
context.SetOutput(!result?.Canceled ?? false
? result.Data as Thing
: null);
}
private readonly IDialogService _dialogService;
private readonly Interaction<Unit, Thing> _getThingInteraction = new();
}
Then my page has a simple button
<MudButton Class="pull-right"
Color="Color.Info"
Variant="Variant.Filled"
StartIcon="@Icons.Material.Filled.Add"
OnClick="() => BindingContext.AddThing(productFormat)">
Add Thing
</MudButton>
When I click the button, I can see the logging whereby the interaction is getting called (IN), but the dialog never shows.
[ VRB ][ wrkr : 1 ] myApp.Portal.Pages.Features.Products.EditProductViewModel : >> GetThingFromDialog
I have tried changing the RenderMode
but that doesn’t seem to accomplish what I need since Interactive Service isn’t supported on WASM.
What do I need to do to get dialogs working again?
Edit
I’ve updated the MainLayout.razor to specify InteractiveWebAssembly
specifically, and still I get the same result.
<MudThemeProvider IsDarkMode="@_isDarkMode" Theme="_theme" @rendermode="RenderMode.InteractiveWebAssembly"/>
<MudPopoverProvider @rendermode="RenderMode.InteractiveWebAssembly"/>
<MudDialogProvider @rendermode="RenderMode.InteractiveWebAssembly"/>
<MudSnackbarProvider @rendermode="RenderMode.InteractiveWebAssembly"/>
9