question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Two-way binding problem with Wrapped AntDesign Select

See original GitHub issue

I 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.

1

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)

  1. Choose Fruit at Select
  2. Parent should show Selected Fruit
  3. 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
cephaspadcommented, Feb 4, 2021

Awesome! Thanks.

1reaction
anddrzejbcommented, Feb 3, 2021

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lag when typing search text in select control · Issue #1965
AntDesign Nuget Package version; Include the output of dotnet --info; The IDE (VS / VS Code/ ... Yeah, it is because of the...
Read more >
Ant Design Dynamic Data does not binds to Select
I am using react for a school project. The dynamic data does not binds to Options from Ant Design, react js. The result...
Read more >
Select - Ant Design
Property Description Default allowClear Show clear button false autoFocus Get focus by default false bordered Whether has border style true
Read more >
Form
This demo shows how to use Form.Item with multiple controls. <Form.Item name="field" /> will only bind the control(Input/Select) which is the only children ......
Read more >
Dropdown
When there are more than a few options to choose from, you can wrap them in a Dropdown . By hovering or clicking...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found