ant-design-blazor / ant-design-blazor

🌈A set of enterprise-class UI components based on Ant Design and Blazor.

Home Page:https://antblazor.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The TreeSelect with single selection raises an excecption when clicking clear icon.

pankey888 opened this issue · comments

Describe the bug

Code:

<TreeSelect
    TItem="Data" Style="width:100%;" DataSource="treeData"
    TItemValue="string"
    Placeholder="Please select"
    @bind-Value="_value"
    AllowClear TreeDefaultExpandAll ChildrenExpression="node=>node.DataItem.Children"
    TitleExpression="node=>node.DataItem.Title" KeyExpression="node=>node.DataItem.Key"
    IsLeafExpression="node=>node.DataItem.Children==null">
</TreeSelect>

_value: @_value

@code {
    private string _value = "1";

    Data[] treeData = new Data[]
    {
        new()
        {
            Title = "Node1",
            Key="1",
            Children = new Data[]
        {
                new()
                {
                    Title = "Child Node1",
                    Key="11",
                },
        }
        },
        new()
        {
            Title = "Node2",
            Key="2",
            Children = new Data[]
        {
                new()
                {
                    Title ="Child Node3",
                    Key="21"
                },
                new()
                {
                    Title ="Child Node4",
                    Key="22",
                },
                new()
                {
                    Title ="Child Node5",
                    Key="23",
                }
        }
        }
    };

    public class Data : ITreeData<Data>
    {
        public string Key { get; set; }
        public Data Value => this;
        public string Title { get; set; }
        public IEnumerable<Data> Children { get; set; }
    }
}

image

Steps to reproduce (please include code)

Exceptions (if any)

Further technical details

  • AntDesign Nuget Package version
  • Include the output of dotnet --info
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and it's version