MudBlazor / MudBlazor

Blazor Component Library based on Material design with an emphasis on ease of use. Mainly written in C# with Javascript kept to a bare minimum it empowers .NET developers to easily debug it if needed.
http://mudblazor.com
MIT License
8.05k stars 1.28k forks source link

MessageBox - Re-rendering action-buttons from content's fragment changes #4773

Open kuebelkasten opened 2 years ago

kuebelkasten commented 2 years ago

Bug type

Component

Component name

MudMessageBox

What happened?

I wanted to add a simple captcha-functionality by letting the user type in a random string into a text-field before he is able to click the Yes button. However, when typing in 'test' the button seems not to update from disabled to enabled. Even tabing out of the text-field does not trigger a re-render of the button. Only when clicking outside the text-field the button is re-rendered.

Expected behavior

As soon as the user typed test into the text-field, the Yes button should be enabled. When typed something other it should be disabled again

Reproduction link

https://try.mudblazor.com/snippet/wamGYqmvxajRVtHM

Reproduction steps

  1. Type t-e-s-t in the text-field
  2. (Yes-button should be enabled)
  3. Type x in the text-field
  4. (Yes-button should be disabled again)

Relevant log output

No response

Version (bug)

6.0.10

Version (working)

No response

What browsers are you seeing the problem on?

Firefox, Chrome, Microsoft Edge

On what operating system are you experiencing the issue?

Windows, iOS

Pull Request

Code of Conduct

IngoManthey commented 2 years ago

use the TextChanged event and if ok StaetHasChanged();

drocha87 commented 2 years ago

use the TextChanged event and if ok StaetHasChanged();

Could you provide an example please?

Because I tried with this demonstration and seems that your solution does not work, you can see in the background that _disabled is changing but it's not affecting the MudButton at all!

Just to provide some context, I changed the MudMessageBox component to show the expected behavior.

americanslon commented 2 years ago

Have you tried Immediate="true" on your MudTextField?

kuebelkasten commented 2 years ago

@americanslon Yes. As can be seen in the issue's snippet 😉 I just omitted the ="true" part as boolean parameters will be set to true when not specified explicitly.

Still I have no idea what is causing this behavior. Ergo, I have no idea how this could be fixed. At least it seems not to be a problem with the <MudButton>. If I add the _disabled property to the YesButton-fragment of @drocha87's example it will show false when typing or tabbing and only true when clicking outside the MudTextField