Skip to content

bug(SelectTree): 设置初始值后无法选中对应项 #4822

@tiansfather

Description

@tiansfather

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

https://github.com/dotnetcore/BootstrapBlazor/issues/988相同,但最新版本9.1.3仍然复现

Expected Behavior

`
@page "/"
@Attribute [TabItemOption(Text = "Index", Closable = false)]
<SelectTree Items="BindItems" Value="@("文件一")">
@code{
private List<TreeViewItem>? BindItems { get; set; } = new List<TreeViewItem>();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
//没有下面这行就能显示选中值
await Task.Yield();
LoadData();

}

private void LoadData()
{
    BindItems =
    [
      new TreeViewItem<string>("目录一")
      {
          Text ="目录一",
          Icon = "fa-solid fa-folder",
          ExpandIcon = "fa-solid fa-folder-open",
          Items =
          [
              new TreeViewItem<string>("子目录一")
              {
                  Text ="子目录一",
                  Icon = "fa-solid fa-folder",
                  ExpandIcon = "fa-solid fa-folder-open",
                  Items =
                  [
                      new TreeViewItem<string>("文件一") { Text = "文件一", Icon = "fa-solid fa-file" },
                      new TreeViewItem<string>("文件二") { Text = "文件二", Icon = "fa-solid fa-file" }
                  ]
              }
          ]
      }
  ];
}

}
`

Interactive render mode

Interactive Server (Interactive server-side rendering (interactive SSR) using Blazor Server)

Steps To Reproduce

image
复现工程.zip

Exceptions (if any)

No response

.NET Version

NET8.0

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingquestionQuestion that needs to be answered

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions