倉庫指標
- 星標
- (10,394 顆星)
- PR 合併指標
- (平均合併 6天 6小時) (30 天內合併 108 個 PR)
描述
Bug type
Component
Component name
MudSelect
What happened?
When MudSelect is in Multiple Selection mode ( with MultiSelection="true" ) and its SelectedValues is bound to IEnumerable<TItem>, an Expression of Func<IEnumerable<TItem>> can not be assigned to For property :the For property expects a Func<TItem>, but the real bound property is of type IEnumerable<TItem>.
so the Data Annotation Validation can not be used with MudSelect in Mltiple Mode.
Expected behavior
for Mudselect component with MultiSelection="true" and when @bind-SelectedValues="@IEnumerable<TItem>" , the For property should accept Func<IEnumerable<TItem>> in order to use Data Annotation Validation
(because the SelectedValues is bound to IEnumerable<TItem>)
Reproduction link
https://try.mudblazor.com/snippet/muQQkgwxyxVUfSSK
Reproduction steps
1.Create new Blazor Webassmbly
2.Add a MudSelect with MultiSelection="true" and bind its SelectedValues to an object of IEnumerable<T> type
<EditForm Model="@person">
<DataAnnotationsValidator />
<MudSelect T="string" Label="Names " MultiSelection="true" Variant="Variant.Outlined" AdornmentIcon="@Icons.Filled.Search"
@bind-SelectedValues="@person.Favorites" Clearable="true" Immediate="true">
@foreach (string aFavorite in AllFavorites)
{
<MudSelectItem T="string" Value="@aFavorite"></MudSelectItem>
}
</MudSelect>
<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary" Class="ml-auto">Register</MudButton>
<MudText Color="@Color.Error">
<ValidationSummary />
</MudText>
</EditForm>
@code{
private IEnumerable<string> AllFavorites=new List<string>
{"Education","Histoy","Movie","Sport"};
public class Person
{
[MinLength(1)]
[Required]
public IEnumerable<string> Favorites{get;set;}=new List<string>();
}
private Person person;
protected override Task OnInitializedAsync()
{
person=new();
return base.OnInitializedAsync();
}
private void OnValidSubmit(EditContext ec)
{
}
}
Relevant log output
No response
Version (bug)
6.0.11-dev.4
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
Pull Request
- I would like to do a Pull Request
Code of Conduct
- I agree to follow this project's Code of Conduct