ant-design-blazor / ant-design-blazor

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

Home Page:https://antblazor.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception on search within TreeSelect.

LukaMajcenic opened this issue · comments

Describe the bug

Exception gets thrown when using search on TreeSelect component.

Steps to reproduce (please include code)

Use <TitleTemplate> fragment instead of Title attribute on <TreeNode> element to reproduce the issue.

<TreeSelect TItem="string" TItemValue="string"
			Style="width:100%;"
			@bind-Values="values"
			DropdownStyle="max-height:400px;overflow:auto;"
			Placeholder="Please select"
			AllowClear
			Multiple
			TreeDefaultExpandAll
			EnableSearch
			MatchedStyle="font-weight: bold">
	<TreeNode TItem="string" Key="parent 1" Title="parent 1">
		<TreeNode TItem="string" Key="parent 1-0" Title="parent 1-0">
			<TreeNode TItem="string" Key="leaf1" Title="my leaf" />
			<TreeNode TItem="string" Key="leaf2" Title="your leaf" />
		</TreeNode>
		<TreeNode TItem="string" Key="parent 1-1" Title="parent 1-1">
			<TreeNode TItem="string" Key="leaf3">
                            <TitleTemplate>
                                <b Style="color:#08c;">leaf3</b>
                            </TitleTemplate>
                        </TreeNode>
		</TreeNode>
	</TreeNode>
</TreeSelect>

Exceptions (if any)

object reference not set to an instance of an object

in Where.cs

Further technical details

  • AntDesign Nuget Package version: 0.19.0
  • .NET SDK version: 8.0.202

One workaround if you want to use <TitleTemplate> is to add Title as well.

<TreeNode TItem="string" Key="leaf3" Title="leaf3">
                            <TitleTemplate>
                                <b Style="color:#08c;">leaf3</b>
                            </TitleTemplate>
                        </TreeNode>

Unfortunatelly, this is not possible if generating using TreeData, making the TreeData feature UNUSABLE.

The problem is not present in 0.18.3

Thanks for contacting us @LukaMajcenic , set the Title parameter is the right way for searching the node with TitleTemplate.

Did you want the TreeData also support TitleTemplate?

Did you want the TreeData also support TitleTemplate?

I'm not sure that would solve anything. The whole point of TreeData is to generate tree without the need for <TreeNode>.

@pankey888 Maybe we can add a SearchExpression for custom searching.