Two-way binding problem with Wrapped AntDesign Select
See original GitHub issueI created an wrapped ofAntDesign Select and use two-binding to get and set child’s Select but it don’t work. The fruitType on parent don’t change anyway.
My sample code is bellow:
Index.razor
@page "/"
<h1>Fruits</h1>
<p>
<FruitSelect @bind-Value="@fruitType" />
</p>
<Paragraph>Parent: @fruitType</Paragraph>
@code {
private FruitType fruitType = FruitType.Unknown;
}
FruitSelect.razor
<Select @bind-Value="@Value" TItem="FruitType" TItemValue="FruitType">
<SelectOptions>
<SelectOption Label="Orange" Value="FruitType.Orange" TItem="FruitType" TItemValue="FruitType" />
<SelectOption Label="Lemon" Value="FruitType.Lemon" TItem="FruitType" TItemValue="FruitType" />
</SelectOptions>
</Select>
<Paragraph>Child: @Value</Paragraph>
@code {
[Parameter]
public FruitType Value { get; set; }
[Parameter]
public EventCallback<FruitType> ValueChanged { get; set; }
}
FruitType.cs
public enum FruitType : int
{
Unknown = 0,
Orange = 1,
Lemon = 2,
}
Describe the bug
the Value in FruitSelect.razor should be reflected to Index.razor but it won’t
Steps to reproduce (please include code)
- Choose Fruit at Select
- Parent should show Selected Fruit
- Child should show Select Fruit (but it won’t)
Source code: AntDesignSample.zip
Further technical details
- AntDesign Nuget Package version: 0.6.0
- Include the output of
dotnet --info
.NET SDK (reflecting any global.json): Version: 5.0.102 Commit: 71365b4d42
Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.102\
Host (useful for support): Version: 5.0.2 Commit: cb5f173b96
.NET SDKs installed: 2.2.207 [C:\Program Files\dotnet\sdk] 3.1.404 [C:\Program Files\dotnet\sdk] 5.0.102 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.24 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
- The IDE (VS / VS Code/ VS4Mac) you’re running on, and it’s version: VS 2019 Community on Windows 10 x64
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Awesome! Thanks.
I just tried it on mine and it worked, but I am working currently on fixing several issues in
Select
component and my code substantially differs from what is in the repo/nuget . I will come back to you once my PR is going to be merged.