fluentui-blazor icon indicating copy to clipboard operation
fluentui-blazor copied to clipboard

UpdaDialogAsync does not update anything in the dialog displayed by DialogService

Open KrystofZacek opened this issue 1 year ago • 2 comments

🐛 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

KrystofZacek avatar May 13 '24 08:05 KrystofZacek

You have to proceed in the same way as for SplashScreen:

  1. Your Content object could contain an UpdateLabels method (see here)
  2. 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

dvoituron avatar May 13 '24 10:05 dvoituron

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.

dvoituron avatar May 13 '24 16:05 dvoituron

Updated in PR #2310.

Will be included in the next Release.

dvoituron avatar Jul 02 '24 10:07 dvoituron