1

In the following MudSelect code:

<MudSelect @bind-Value="value" T="string" Label="Test Select" Error="@isInError" ErrorText="The field is in error">
    @foreach(string option in options)
    {
        <MudSelectItem T="string" Value="@option">@option</MudSelectItem>
    }
</MudSelect>

<MudButton ButtonType="ButtonType.Button" onclick="@Validate">Validate</MudButton>

@code {
    private bool isInError = false;

    private string value = string.Empty;
    
    private List<string> options = ["opt1", "opt2", "opt3", "opt4"];
        
    private void Validate()
    {
        if (value == string.Empty)
        {
            isInError = true;
        }
    }
}

Code snippet: https://try.mudblazor.com/snippet/QuczkymnkhIRBAhH

If you select no option and click on the validate button, the error message appears (as expected).

But when you select an option, the error message disappears and the highlighting changes back to normal state.

I don't want this. I only want the error processing to happen on the validate click primarily as the error may not be related to the field being blank or not. There are also other components on the screen that don't suffer from the same behaviour, like MudTextField.

I cannot seem to find anything on the issues log relating to this. I'm using mudblazor v8.5.1.

Does anyone have any ideas on how to fix this?

6
  • Selecting an option causes a redraw. When the redraw happens, isInError is false. Commented Apr 23 at 14:20
  • Hi L0uis, not sure what you are saying is correct. Check out this code snippet try.mudblazor.com/snippet/wamzaewnsznNvIpH. After the select both the components error variable and my isInError are still both true but the error validation has been cleared. Commented Apr 23 at 23:45
  • I'd recommend opening an issue on their GitHub, don't see a way to achieve what you want, with the way Error works right now. Commented Apr 28 at 8:16
  • 1
    @RBee - I came to the same conclusion this morning and raised an issue on their log. I'll update this thread when I know more. It appears to be an error that affects this component only. MudTextField and the others don't have the same issue. Commented Apr 28 at 13:28
  • @user21415940 im having the same problem as you, has there been any update on this Commented Jul 17 at 8:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.