@@ -14,13 +14,6 @@ namespace BootstrapBlazor.Components;
1414/// <typeparam name="TValue">The type of the value.</typeparam>
1515public partial class AutoFill < TValue >
1616{
17- /// <summary>
18- /// Gets the component style.
19- /// </summary>
20- private string ? ClassString => CssBuilder . Default ( "auto-complete auto-fill" )
21- . AddClass ( "is-clearable" , IsClearable )
22- . Build ( ) ;
23-
2417 /// <summary>
2518 /// Gets or sets the collection of items for the component.
2619 /// </summary>
@@ -119,19 +112,6 @@ public partial class AutoFill<TValue>
119112 [ NotNull ]
120113 public Func < VirtualizeQueryOption , Task < QueryData < TValue > > > ? OnQueryAsync { get ; set ; }
121114
122- /// <summary>
123- /// Gets or sets whether the select component is clearable. Default is false.
124- /// </summary>
125- [ Parameter ]
126- public bool IsClearable { get ; set ; }
127-
128- /// <summary>
129- /// Gets or sets the right-side clear icon. Default is fa-solid fa-angle-up.
130- /// </summary>
131- [ Parameter ]
132- [ NotNull ]
133- public string ? ClearIcon { get ; set ; }
134-
135115 /// <summary>
136116 /// Gets or sets the callback method when the clear button is clicked. Default is null.
137117 /// </summary>
@@ -154,6 +134,13 @@ public partial class AutoFill<TValue>
154134 [ NotNull ]
155135 private RenderTemplate ? _dropdown = null ;
156136
137+ /// <summary>
138+ /// Gets the component style.
139+ /// </summary>
140+ private string ? ClassString => CssBuilder . Default ( "auto-complete auto-fill" )
141+ . AddClass ( "is-clearable" , IsClearable )
142+ . Build ( ) ;
143+
157144 /// <summary>
158145 /// Gets the clear icon class string.
159146 /// </summary>
@@ -178,7 +165,6 @@ protected override void OnParametersSet()
178165 PlaceHolder ??= Localizer [ nameof ( PlaceHolder ) ] ;
179166 Icon ??= IconTheme . GetIconByKey ( ComponentIcons . AutoFillIcon ) ;
180167 LoadingIcon ??= IconTheme . GetIconByKey ( ComponentIcons . LoadingIcon ) ;
181- ClearIcon ??= IconTheme . GetIconByKey ( ComponentIcons . SelectClearIcon ) ;
182168
183169 _displayText = GetDisplayText ( Value ) ;
184170 Items ??= [ ] ;
@@ -190,7 +176,6 @@ protected override void OnParametersSet()
190176 /// <returns></returns>
191177 protected override Task InvokeInitAsync ( ) => InvokeVoidAsync ( "init" , Id , Interop , _displayText ) ;
192178
193-
194179 private bool IsNullable ( ) => ! ValueType . IsValueType || NullableUnderlyingType != null ;
195180
196181 /// <summary>
@@ -199,30 +184,6 @@ protected override void OnParametersSet()
199184 /// <returns></returns>
200185 private bool GetClearable ( ) => IsClearable && ! IsDisabled && IsNullable ( ) ;
201186
202- /// <summary>
203- /// <inheritdoc/>
204- /// </summary>
205- /// <returns></returns>
206- private async Task OnClearValue ( )
207- {
208- // 使用脚本更新 input 值
209- await InvokeVoidAsync ( "setValue" , Id , "" ) ;
210-
211- if ( OnClearAsync != null )
212- {
213- await OnClearAsync ( ) ;
214- }
215- CurrentValue = default ;
216- _displayText = null ;
217- _filterItems = null ;
218- _searchText = null ;
219-
220- if ( OnQueryAsync != null )
221- {
222- await _virtualizeElement . RefreshDataAsync ( ) ;
223- }
224- }
225-
226187 /// <summary>
227188 /// Callback method when a candidate item is clicked.
228189 /// </summary>
@@ -269,6 +230,18 @@ private async ValueTask<ItemsProviderResult<TValue>> LoadItems(ItemsProviderRequ
269230 [ JSInvokable ]
270231 public async Task TriggerFilter ( string val )
271232 {
233+ if ( string . IsNullOrEmpty ( val ) )
234+ {
235+ CurrentValue = default ;
236+ _filterItems = null ;
237+ _displayText = null ;
238+
239+ if ( OnClearAsync != null )
240+ {
241+ await OnClearAsync ( ) ;
242+ }
243+ }
244+
272245 if ( OnQueryAsync != null )
273246 {
274247 _searchText = val ;
0 commit comments