Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdaDialogAsync does not update anything in the dialog displayed by DialogService #2040

Open
KrystofZacek opened this issue May 13, 2024 · 2 comments
Assignees
Labels
feature A new feature

Comments

@KrystofZacek
Copy link

馃悰 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

@microsoft-github-policy-service microsoft-github-policy-service bot added the triage New issue. Needs to be looked at label May 13, 2024
@dvoituron
Copy link
Collaborator

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 dvoituron reopened this May 13, 2024
@dvoituron
Copy link
Collaborator

From Discord:

Why so much manual wiring? There already is a method DialogService.UpdateDialogAsync(dialogId, params).
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 dvoituron self-assigned this May 29, 2024
@dvoituron dvoituron added feature A new feature and removed triage New issue. Needs to be looked at labels May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature A new feature
Projects
None yet
Development

No branches or pull requests

2 participants