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
7.98k stars 1.27k forks source link

MudTextField do not working in .NET 8.0 version WebAssembly #9488

Closed oliverigor27 closed 2 months ago

oliverigor27 commented 2 months ago

Things to check

Bug type

Component

Component name

MudTextField

What happened?

I'm trying to use MudTextField in a application but it does not working well. It does not recognize the properties in MudTextField and looks like is not reading the input.

Captura de Tela 2024-07-23 às 14 48 24

That is what i'm doing:

                <MudTextField 
                    Class="input-fields" 
                    Label="Username" 
                    Variant="Variant.Outlined"
                    @bind-Value="@LoginModel.CPF" 
                    Mask="@(new PatternMask("000.000.000-00"))" 
                />

This is inside a with a Model, a On valid and invalid submit

Expected behavior

Captura de Tela 2024-07-23 às 15 02 02

Reproduction link

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

Reproduction steps

  1. I try to write something in the input
  2. The mask that should be applied do not work
  3. Even with a valid value, it do not send an return a validation error ...

Relevant log output

No response

Version (bug)

7.4.0

Version (working)

6.20.0

What browsers are you seeing the problem on?

Chrome

On which operating systems are you experiencing the issue?

macOS

Pull Request

Code of Conduct

ScarletKuro commented 2 months ago

I copied your code from the reproduction link:

Reproduction link https://try.mudblazor.com/snippet/wEcSuVGHUpcGWDmg

I pasted it into a project created from the official MudBlazor Templates for WebApp. It's using .NET 8.0, MudBlazor 7.4.0, and WebAssembly global interactivity, and I see no problem.

working

TryMudblazor is also using the latest version and is a standalone WebAssembly (not WebApp), and as you can see, it's working there too. Please check your application configuration. I suggest you try our templates.

ScarletKuro commented 2 months ago

Unless I misunderstand something, but in repro steps it says:

The mask that should be applied do not work

But I see that mask is being applied.

Even with a valid value, it do not send an return a validation error

This I don't really understand, but if the question is why the validation is not working, then you are missing a lot of things like <DataAnnotationsValidator/> and For="@(() => loginModel.UserRegister)", please refer to https://mudblazor.com/components/form#editform-support sample

oliverigor27 commented 2 months ago

Unless I misunderstand something, but in repro steps it says:

The mask that should be applied do not work

But I see that mask is being applied.

Even with a valid value, it do not send an return a validation error

This I don't really understand, but if the question is why the validation is not working, then you are missing a lot of things like <DataAnnotationsValidator/> and For="@(() => loginModel.UserRegister)", please refer to https://mudblazor.com/components/form#editform-support sample

The validation is Working, the problem is the behavior of the MudTextField. It's invaliding any attempt to send a request to the backend and is having the behavior that i showed in the print.

ScarletKuro commented 2 months ago

The validation is Working, the problem is the behavior of the MudTextField. It's invaliding any attempt to send a request to the backend and is having the behavior that i showed in the print.

You need to elaborate much more and provide more info on what the actual problem is. Perhaps it would be better to provide a simple reproduction project via zip or repository.

Your TryMudBlazor sample doesn't have a backend request, but I can clearly see that the OnValidSubmit is being executed on login and the value is updated: updates

This contradicts everything you said above. It looks like you are not running any interactivity mode with MudTextField, which is why you are having all these problems. This is expected, as static SSR is not supported.

oliverigor27 commented 2 months ago

The validation is Working, the problem is the behavior of the MudTextField. It's invaliding any attempt to send a request to the backend and is having the behavior that i showed in the print.

You need to elaborate much more and provide more info on what the actual problem is. Perhaps it would be better to provide a simple reproduction project via zip or repository.

Your TryMudBlazor sample doesn't have a backend request, but I can clearly see that the OnValidSubmit is being executed on login and the value is updated: updates

This contradicts everything you said above. It looks like you are not running any interactivity mode with MudTextField, which is why you are having all these problems. This is expected, as static SSR is not supported.

I made a sample, you can see here: https://github.com/oliverigor27/AplicacaoTeste.git

ScarletKuro commented 2 months ago

I made a sample, you can see here: https://github.com/oliverigor27/AplicacaoTeste.git

But this setup is absolutely not correct:

  1. You said it's WebAssembly, but it's using just the InteractiveServer, which means it doesn't use WASM at all.
  2. It's not a complete setup. You are missing <HeadOutlet @rendermode="InteractiveServer"/> and <Routes @rendermode="InteractiveServer" /> in App.razor, which are important parts when setting up your WebApp. Of course, it will not work as your page is rendered as static, not interactive.
  3. Where did you get OnValueChanged from? It doesn't exist in MudBlazor.
oliverigor27 commented 2 months ago

I made a sample, you can see here: https://github.com/oliverigor27/AplicacaoTeste.git

But this setup is absolutely not correct:

  1. You said it's WebAssembly, but it's using just the InteractiveServer, which means it doesn't use WASM at all.
  2. It's not a complete setup. You are missing <HeadOutlet @rendermode="InteractiveServer"/> and <Routes @rendermode="InteractiveServer" /> in App.razor, which are important parts when setting up your WebApp. Of course, it will not work as your page is rendered as static, not interactive.
  3. Where did you get OnValueChanged from? It doesn't exist in MudBlazor.

Oh, i didn't knew about that. I'm sorry, i'm a back-end trying to do a webpage. Thank you again!