UpdaDialogAsync does not update anything in the dialog displayed by DialogService
🐛 Bug Report
Calling UpdaDialogAsync does not update anything in the dialog displayed by DialogService.
For instance try to change the Title or Content does nothing to the dialog.
💻 Repro or Code Sample
DialogParameters<SimplePerson> parameters = new()
{
Title = $"Hello {simplePerson.Firstname}",
PrimaryAction = "Yes",
PrimaryActionEnabled = false,
SecondaryAction = "No",
Width = "500px",
TrapFocus = _trapFocus,
Modal = _modal,
PreventScroll = true
};
IDialogReference dialog = await DialogService.ShowDialogAsync<SimpleDialog>(simplePerson, parameters);
await Task.Delay(1000);
// Let's change some params and data in the dialog
parameters.Title = "Changed title";
parameters.PrimaryAction = "Oh yes";
parameters.Content = new() { Firstname = "John", Lastname = "Brown",Age = 50};
await DialogService.UpdateDialogAsync<SimplePerson>(dialog.Id, parameters); // nothing changes in the dialog
await Task.Delay(1000);
🤔 Expected Behavior
😯 Current Behavior
🔦 Context
🌍 Your Environment
You have to proceed in the same way as for SplashScreen:
- Your Content object could contain an
UpdateLabelsmethod (see here) - So, you can call this method as you want:
var splashScreen = (SplashScreenContent)_dialog.Instance.Content;
splashScreen.UpdateLabels(loadingText: "Second task...");
Example: Open splash screen (async) button - https://www.fluentui-blazor.net/SplashScreen
From Discord:
Why so much manual wiring? There already is a method DialogService.UpdateDialogAsync<MyContent>(dialogId, params<MyContent>). It even invokes StateHasChanged in the dialog. It just DOES NOT pass the Content in params.Content to the dialog. What is then the purpose of DialogService.UpdateDialogAsync at all?
Me: Indeed, it's probably something we could adapt.
Updated in PR #2310.
Will be included in the next Release.