diff --git a/src/BootstrapBlazor.Server/Components/Samples/Selects.razor.cs b/src/BootstrapBlazor.Server/Components/Samples/Selects.razor.cs
index 4c2eb39bbdf..342b2117f46 100644
--- a/src/BootstrapBlazor.Server/Components/Samples/Selects.razor.cs
+++ b/src/BootstrapBlazor.Server/Components/Samples/Selects.razor.cs
@@ -321,6 +321,14 @@ private AttributeItem[] GetAttributes() =>
DefaultValue = "false"
},
new()
+ {
+ Name = "IsAutoClearSearchTextWhenCollapsed",
+ Description = Localizer["SelectsIsAutoClearSearchTextWhenCollapsed"],
+ Type = "bool",
+ ValueList = "true|false",
+ DefaultValue = "false"
+ },
+ new()
{
Name = "DisplayText",
Description = Localizer["SelectsDisplayText"],
diff --git a/src/BootstrapBlazor.Server/Locales/en-US.json b/src/BootstrapBlazor.Server/Locales/en-US.json
index c0a3000adce..04a5dd1a7cc 100644
--- a/src/BootstrapBlazor.Server/Locales/en-US.json
+++ b/src/BootstrapBlazor.Server/Locales/en-US.json
@@ -3211,7 +3211,7 @@
"SelectsCustomTemplateTitle": "Custom option templates",
"SelectsCustomTemplateIntro": "By setting the ItemTemplate you can customize the option rendering style",
"SelectsShowSearchTitle": "Drop-down box with search box",
- "SelectsShowSearchIntro": "Controls whether the search box is displayed by setting the ShowSearch property, which is not displayed by default false",
+ "SelectsShowSearchIntro": "Controls whether the search box is displayed by setting the ShowSearch property, which is not displayed by default false. You can set the IsAutoClearSearchTextWhenCollapsed parameter to control whether the text in the search box is automatically cleared after the drop-down box is collapsed. The default value is false.",
"SelectsConfirmSelectTitle": "Drop-down box with confirmation",
"SelectsConfirmSelectIntro": "Block changes to the current value by setting the OnBeforeSelectedItemChange delegate.",
"SelectsTimeZoneTitle": "Timezone",
@@ -3221,6 +3221,7 @@
"SwalFooter": "Click Confirm to change the option value and select Cancel to leave the value unchanged",
"SelectsShowLabel": "Whether to display the front label",
"SelectsShowSearch": "Whether to display the search box",
+ "SelectsIsAutoClearSearchTextWhenCollapsed": "Whether to automatically clear the search bar when the drop-down box is collapsed",
"SelectsDisplayText": "The front label displays text",
"SelectsClass": "Style",
"SelectsColor": "Color",
diff --git a/src/BootstrapBlazor.Server/Locales/zh-CN.json b/src/BootstrapBlazor.Server/Locales/zh-CN.json
index d32ba236160..c5478c69f93 100644
--- a/src/BootstrapBlazor.Server/Locales/zh-CN.json
+++ b/src/BootstrapBlazor.Server/Locales/zh-CN.json
@@ -3211,7 +3211,7 @@
"SelectsCustomTemplateTitle": "自定义选项模板",
"SelectsCustomTemplateIntro": "通过设置 ItemTemplate 可以自定义选项渲染样式",
"SelectsShowSearchTitle": "带搜索框的下拉框",
- "SelectsShowSearchIntro": "通过设置 ShowSearch 属性控制是否显示搜索框,默认为 false 不显示搜索框",
+ "SelectsShowSearchIntro": "通过设置 ShowSearch 属性控制是否显示搜索框,默认为 false 不显示搜索框,可以通过设置 IsAutoClearSearchTextWhenCollapsed 参数控制下拉框收起后是否自动清空搜索框内文字,默认值为 false 不清空",
"SelectsConfirmSelectTitle": "带确认的下拉框",
"SelectsConfirmSelectIntro": "通过设置 OnBeforeSelectedItemChange 委托,阻止当前值的改变",
"SelectsTimeZoneTitle": "时区下拉框",
@@ -3221,6 +3221,7 @@
"SwalFooter": "点击确认改变选项值,选择取消后值不变",
"SelectsShowLabel": "是否显示前置标签",
"SelectsShowSearch": "是否显示搜索框",
+ "SelectsIsAutoClearSearchTextWhenCollapsed": "下拉框收起时是否自动清空搜索栏",
"SelectsDisplayText": "前置标签显示文本",
"SelectsClass": "样式",
"SelectsColor": "颜色",
diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj
index 44b52dd7b2e..1ba7569b506 100644
--- a/src/BootstrapBlazor/BootstrapBlazor.csproj
+++ b/src/BootstrapBlazor/BootstrapBlazor.csproj
@@ -1,7 +1,7 @@
- 9.6.2-beta05
+ 9.6.2-beta06
diff --git a/src/BootstrapBlazor/Components/Select/Select.razor.cs b/src/BootstrapBlazor/Components/Select/Select.razor.cs
index ace96cecc2e..4f6f2434056 100644
--- a/src/BootstrapBlazor/Components/Select/Select.razor.cs
+++ b/src/BootstrapBlazor/Components/Select/Select.razor.cs
@@ -18,26 +18,13 @@ public partial class Select : ISelect, ILookup
[NotNull]
private SwalService? SwalService { get; set; }
- private string? ClassString => CssBuilder.Default("select dropdown")
- .AddClass("is-clearable", IsClearable)
- .AddClassFromAttributes(AdditionalAttributes)
- .Build();
-
- private string? InputClassString => CssBuilder.Default("form-select form-control")
- .AddClass($"border-{Color.ToDescriptionString()}", Color != Color.None && !IsDisabled && !IsValid.HasValue)
- .AddClass($"border-success", IsValid.HasValue && IsValid.Value)
- .AddClass($"border-danger", IsValid.HasValue && !IsValid.Value)
- .AddClass(CssClass).AddClass(ValidCss)
- .Build();
-
- private string? ActiveItem(SelectedItem item) => CssBuilder.Default("dropdown-item")
- .AddClass("active", item.Value == CurrentValueAsString)
- .AddClass("disabled", item.IsDisabled)
- .Build();
-
- private readonly List _children = [];
+ [Inject]
+ [NotNull]
+ private IStringLocalizer