Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/BootstrapBlazor/Components/Search/Search.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public partial class Search<TValue>
/// Gets or sets the callback delegate when the search button is clicked.
/// </summary>
[Parameter]
public Func<string, Task<IEnumerable<TValue>>>? OnSearch { get; set; }
public Func<string?, Task<IEnumerable<TValue>>>? OnSearch { get; set; }

/// <summary>
/// Gets or sets the callback method to get display text. Default is null, using ToString() method.
Expand Down Expand Up @@ -200,13 +200,16 @@ protected override void OnParametersSet()
NoDataTip ??= Localizer[nameof(NoDataTip)];
_filterItems ??= [];

// 这里应该获得初始值
_displayText = GetDisplayText(Value);

if (Debounce == 0)
{
Debounce = 200;
}
}

private string _displayText = "";
private string? _displayText;
private async Task OnSearchClick()
{
if (OnSearch != null)
Expand All @@ -226,7 +229,7 @@ private async Task OnSearchClick()

private async Task OnClearClick()
{
_displayText = "";
_displayText = null;
if (OnClear != null)
{
await OnClear();
Expand All @@ -247,7 +250,7 @@ private async Task OnClearClick()
private async Task OnClickItem(TValue val)
{
CurrentValue = val;
_displayText = GetDisplayText(val) ?? "";
_displayText = GetDisplayText(val);

if (OnSelectedItemChanged != null)
{
Expand Down
Loading