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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MudDialog not updating contents properly #1016

Closed
elylv opened this issue Feb 26, 2021 · 6 comments
Closed

MudDialog not updating contents properly #1016

elylv opened this issue Feb 26, 2021 · 6 comments
Assignees
Labels
bug Something does not work as intended/expected fixed Fix has been merged
Milestone

Comments

@elylv
Copy link

elylv commented Feb 26, 2021

I've been scratching my head, trying to work out what's going on with my code here: #998

Something that works as expected in TryMudBlazor, but is just being weird in my project. I assumed it was something wrong with my project setup, but I've just created a brand new Blazor WASM project in VS, and only added MudBlazor, and tried the code here:
https://try.mudblazor.com/snippet/wuwvOQcAeicnQbuY

There is a definite mismatch in how the code behaves between the clean project, and TryMudBlazor. The TryMudBlazor code works as it should. The same code in a blank project does not work as expected.

Opening the dialog box, then clicking the slider toggle, the slider should not toggle (or toggle on then immediately back to off), nor should the "Setting" text. Also, an "ERROR!" message should appear beneath the slider.

Running the code on my system, when you open the dialog and click the toggle, the toggle control actually does toggle to On. The "Setting" text does not change. The "ERROR!" message does not appear.
If you subsequently right-click somewhere within the dialog box, the contents then seem to re-render as they should.

It seems for some reason, the dialog contents are not rerendering properly when their state changes. Throwing in liberal StateHasChanged()s does not make any difference.

@elylv elylv added the bug Something does not work as intended/expected label Feb 26, 2021
@porkopek
Copy link
Contributor

Could you make a github repo with a minimal reproduction so I can checkout and make a PR to fix it?

@elylv
Copy link
Author

elylv commented Feb 26, 2021

https://github.com/elylv/MudBlazor-Dialog-Issue1016

It's basically a fresh Blazor WASM (.net core backend), with MudBlazor nuget added, and the issue is shown in the Index.razor file (click the "Open" button when running to get the dialog up with the issue on display).

@porkopek
Copy link
Contributor

I definitely am able to reproduce it.
It happens both in BSS and WASM.

It seems that this is related only to Inlined Dialogs.
With injected dialogs doesn't happen. In the meantime, while we fix this, could you use an injected dialog service?
See the first example of https://mudblazor.com/components/dialog

@porkopek
Copy link
Contributor

porkopek commented Feb 28, 2021

A minimal example to reproduce this is

<MudText>count is @_count</MudText>
<MudButton OnClick="@((e) => {isOpen=true;})">Open</MudButton>

<MudDialog @bind-IsVisible="@isOpen">

    <DialogContent>
        <MudButton OnClick=@AddOne>Click me</MudButton>
        <MudText>count is @_count</MudText>
    </DialogContent>
</MudDialog>
@code {
    int _count = 0;
    bool isOpen = false;

    public void AddOne()
    {
        _count++;
    }
}

It works in tryMudBlazor but doesn't in VS, nor Blazor Server Side nor WASM.
The _count value is not updated inside the Dialog until you click in the text that displays the count inside dialog

@henon Do you have any idea? You're the Dialog expert

@henon
Copy link
Collaborator

henon commented Feb 28, 2021

Thanks for providing the repro sample @porkopek. I am looking at it

henon added a commit that referenced this issue Feb 28, 2021
(cherry picked from commit 82088d4d7c9874568bc92a414650aa418d125b1e)
@henon henon added this to the 5.0.3 milestone Feb 28, 2021
@henon henon added the fixed Fix has been merged label Feb 28, 2021
@henon henon self-assigned this Feb 28, 2021
@henon
Copy link
Collaborator

henon commented Feb 28, 2021

Fixed by forwarding render updates to the shown instance of the inlined dialog

@henon henon closed this as completed Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as intended/expected fixed Fix has been merged
Projects
None yet
Development

No branches or pull requests

3 participants