Skip to content

Commit 980c1ff

Browse files
committed
feat(AutoFill): always filter the dropdown items by input text (#5842)
* doc: 注释更新为英语 * refactor: 选择后更新下拉框 * refactor: 调整参数 * refactor: 移除代码
1 parent 7818266 commit 980c1ff

File tree

3 files changed

+28
-38
lines changed

3 files changed

+28
-38
lines changed

src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ private async Task OnClickItem(string val)
135135
{
136136
await OnBlurAsync(Value);
137137
}
138+
139+
await TriggerFilter(val);
138140
}
139141

140142
private List<string> Rows => _filterItems ?? [.. Items];

src/BootstrapBlazor/Components/AutoFill/AutoFill.razor.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ private async Task OnClickItem(TValue val)
232232
{
233233
await OnBlurAsync(Value);
234234
}
235+
236+
await TriggerFilter(_displayText!);
235237
}
236238

237239
private string? GetDisplayText(TValue item) => OnGetDisplayText?.Invoke(item) ?? item?.ToString();

src/BootstrapBlazor/Components/Search/Search.razor.cs

Lines changed: 24 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,142 +8,142 @@
88
namespace BootstrapBlazor.Components;
99

1010
/// <summary>
11-
/// Search 组件
11+
/// Search component
1212
/// </summary>
1313
public partial class Search<TValue>
1414
{
1515
/// <summary>
16-
/// 获得/设置 图标模板 默认 null 未设置
16+
/// Gets or sets the icon template. Default is null if not set.
1717
/// </summary>
1818
[Parameter]
1919
public RenderFragment<SearchContext<TValue>>? IconTemplate { get; set; }
2020

2121
/// <summary>
22-
/// 获得/设置 是否显示清空小按钮 默认 false
22+
/// Gets or sets whether to show the clear button. Default is false.
2323
/// </summary>
2424
[Parameter]
2525
public bool IsClearable { get; set; }
2626

2727
/// <summary>
28-
/// 获得/设置 清空图标 默认为 null
28+
/// Gets or sets the clear icon. Default is null.
2929
/// </summary>
3030
[Parameter]
3131
public string? ClearIcon { get; set; }
3232

3333
/// <summary>
34-
/// 获得/设置 是否显示清除按钮 默认为 false 不显示
34+
/// Gets or sets whether to show the clear button. Default is false.
3535
/// </summary>
3636
[Parameter]
3737
public bool ShowClearButton { get; set; }
3838

3939
/// <summary>
40-
/// Clear button icon
40+
/// Gets or sets the icon of clear button. Default is null.
4141
/// </summary>
4242
[Parameter]
4343
public string? ClearButtonIcon { get; set; }
4444

4545
/// <summary>
46-
/// Clear button text
46+
/// Gets or sets the text of clear button. Default is null.
4747
/// </summary>
4848
[Parameter]
4949
public string? ClearButtonText { get; set; }
5050

5151
/// <summary>
52-
/// Clear button color
52+
/// Gets or sets the color of clear button. Default is <see cref="Color.Primary"/>.
5353
/// </summary>
5454
[Parameter]
5555
public Color ClearButtonColor { get; set; } = Color.Primary;
5656

5757
/// <summary>
58-
/// 获得/设置 是否显示搜索按钮 默认为 true 显示
58+
/// Gets or sets whether to show the search button. Default is true.
5959
/// </summary>
6060
[Parameter]
6161
public bool ShowSearchButton { get; set; } = true;
6262

6363
/// <summary>
64-
/// 获得/设置 搜索按钮颜色
64+
/// Gets or sets the search button color. Default is <see cref="Color.Primary"/>.
6565
/// </summary>
6666
[Parameter]
6767
public Color SearchButtonColor { get; set; } = Color.Primary;
6868

6969
/// <summary>
70-
/// 获得/设置 搜索按钮图标
70+
/// Gets or sets the search button icon. Default is null.
7171
/// </summary>
7272
[Parameter]
7373
public string? SearchButtonIcon { get; set; }
7474

7575
/// <summary>
76-
/// 获得/设置 正在搜索按钮图标
76+
/// Gets or sets the loading icon for the search button. Default is null.
7777
/// </summary>
7878
[Parameter]
7979
public string? SearchButtonLoadingIcon { get; set; }
8080

8181
/// <summary>
82-
/// 获得/设置 搜索按钮文字
82+
/// Gets or sets the search button text. Default is null.
8383
/// </summary>
8484
[Parameter]
8585
[NotNull]
8686
public string? SearchButtonText { get; set; }
8787

8888
/// <summary>
89-
/// 获得/设置 按钮模板 默认 null 未设置
89+
/// Gets or sets the button template. Default is null.
9090
/// </summary>
9191
[Parameter]
9292
public RenderFragment<SearchContext<TValue>>? ButtonTemplate { get; set; }
9393

9494
/// <summary>
95-
/// 获得/设置 前置按钮模板 默认 null 未设置
95+
/// Gets or sets the prefix button template. Default is null.
9696
/// </summary>
9797
[Parameter]
9898
public RenderFragment<SearchContext<TValue>>? PrefixButtonTemplate { get; set; }
9999

100100
/// <summary>
101-
/// 获得/设置 是否显示前缀图标 默认为 false 不显示
101+
/// Gets or sets whether to show the prefix icon. Default is false.
102102
/// </summary>
103103
[Parameter]
104104
public bool ShowPrefixIcon { get; set; }
105105

106106
/// <summary>
107-
/// 获得/设置 前缀图标 默认为 null
107+
/// Gets or sets the prefix icon. Default is null.
108108
/// </summary>
109109
[Parameter]
110110
public string? PrefixIcon { get; set; }
111111

112112
/// <summary>
113-
/// 获得/设置 前缀图标模板 默认为 null
113+
/// Gets or sets the prefix icon template. Default is null.
114114
/// </summary>
115115
[Parameter]
116116
public RenderFragment<SearchContext<TValue>>? PrefixIconTemplate { get; set; }
117117

118118
/// <summary>
119-
/// 获得/设置 点击搜索后是否自动清空搜索框
119+
/// Gets or sets whether to automatically clear the search box after searching. Deprecated.
120120
/// </summary>
121121
[Parameter]
122-
[Obsolete("已弃用,删除即可; Deprecated. Just delete it")]
122+
[Obsolete("Deprecated. Just delete it.")]
123123
[ExcludeFromCodeCoverage]
124124
public bool IsAutoClearAfterSearch { get; set; }
125125

126126
/// <summary>
127-
/// 获得/设置 搜索模式是否为输入即触发 默认 true 值为 false 时需要点击搜索按钮触发
127+
/// Gets or sets whether the search is triggered by input. Default is true. If false, the search button must be clicked to trigger.
128128
/// </summary>
129129
[Parameter]
130130
public bool IsTriggerSearchByInput { get; set; } = true;
131131

132132
/// <summary>
133-
/// 获得/设置 点击搜索按钮时回调委托
133+
/// Gets or sets the callback delegate when the search button is clicked.
134134
/// </summary>
135135
[Parameter]
136136
public Func<string, Task<IEnumerable<TValue>>>? OnSearch { get; set; }
137137

138138
/// <summary>
139-
/// 获得/设置 通过模型获得显示文本方法 默认使用 ToString 重载方法
139+
/// Gets or sets the callback method to get display text. Default is null, using ToString() method.
140140
/// </summary>
141141
[Parameter]
142142
[NotNull]
143143
public Func<TValue, string?>? OnGetDisplayText { get; set; }
144144

145145
/// <summary>
146-
/// 获得/设置 点击清空按钮时回调委托
146+
/// Gets or sets the event callback when the clear button is clicked. Default is null.
147147
/// </summary>
148148
[Parameter]
149149
public Func<string?, Task>? OnClear { get; set; }
@@ -163,9 +163,6 @@ public partial class Search<TValue>
163163
[NotNull]
164164
private string? ButtonIcon { get; set; }
165165

166-
/// <summary>
167-
/// 获得/设置 UI 呈现数据集合
168-
/// </summary>
169166
[NotNull]
170167
private List<TValue>? _filterItems = null;
171168

@@ -210,10 +207,6 @@ protected override void OnParametersSet()
210207
}
211208

212209
private string _displayText = "";
213-
/// <summary>
214-
/// 点击搜索按钮时触发此方法
215-
/// </summary>
216-
/// <returns></returns>
217210
private async Task OnSearchClick()
218211
{
219212
if (OnSearch != null)
@@ -232,10 +225,6 @@ private async Task OnSearchClick()
232225
}
233226
}
234227

235-
/// <summary>
236-
/// 点击搜索按钮时触发此方法
237-
/// </summary>
238-
/// <returns></returns>
239228
private async Task OnClearClick()
240229
{
241230
if (OnClear != null)
@@ -256,9 +245,6 @@ private async Task OnClearClick()
256245
return displayText;
257246
}
258247

259-
/// <summary>
260-
/// 鼠标点击候选项时回调此方法
261-
/// </summary>
262248
private async Task OnClickItem(TValue val)
263249
{
264250
CurrentValue = val;

0 commit comments

Comments
 (0)