Skip to content

Commit ead68ff

Browse files
committed
refactor: 移动 ShowDropdownListOnFocus 到实现类
1 parent 4e02045 commit ead68ff

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,24 @@ public partial class AutoComplete
6363
[Parameter]
6464
public bool IgnoreCase { get; set; } = true;
6565

66+
/// <summary>
67+
/// 获得/设置 获得焦点时是否展开下拉候选菜单 默认 true
68+
/// </summary>
69+
[Parameter]
70+
public bool ShowDropdownListOnFocus { get; set; } = true;
71+
6672
/// <summary>
6773
/// IStringLocalizer 服务实例
6874
/// </summary>
6975
[Inject]
7076
[NotNull]
7177
private IStringLocalizer<AutoComplete>? Localizer { get; set; }
7278

79+
/// <summary>
80+
/// 获得 获得焦点自动显示下拉框设置字符串
81+
/// </summary>
82+
private string? ShowDropdownListOnFocusString => ShowDropdownListOnFocus ? "true" : null;
83+
7384
/// <summary>
7485
/// <inheritdoc/>
7586
/// </summary>

src/BootstrapBlazor/Components/AutoComplete/AutoComplete.razor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function init(id, invoke) {
3333
}
3434

3535
EventHandler.on(input, 'focus', e => {
36-
const showDropdownOnFocus = input.getAttribute('data-bb-auto-dropdown-focus') !== 'false';
36+
const showDropdownOnFocus = input.getAttribute('data-bb-auto-dropdown-focus') === 'true';
3737
if (showDropdownOnFocus) {
3838
if (ac.popover === void 0) {
3939
el.classList.add('show');
@@ -61,7 +61,7 @@ const handlerKeyup = (ac, e) => {
6161
const skipEnter = el.getAttribute('data-bb-skip-enter') === 'true';
6262
if (!skipEnter) {
6363
const current = menu.querySelector('.active');
64-
if(current !== null) {
64+
if (current !== null) {
6565
current.click();
6666
}
6767
}

src/BootstrapBlazor/Components/AutoComplete/PopoverCompleteBase.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ public abstract class PopoverCompleteBase<TValue> : BootstrapInputBase<TValue>,
6262
[Parameter]
6363
public string? Offset { get; set; }
6464

65-
/// <summary>
66-
/// 获得/设置 获得焦点时是否展开下拉候选菜单 默认 true
67-
/// </summary>
68-
[Parameter]
69-
public bool ShowDropdownListOnFocus { get; set; } = true;
70-
7165
/// <summary>
7266
/// 获得/设置 防抖时间 默认为 0 即不开启
7367
/// </summary>
@@ -155,11 +149,6 @@ public abstract class PopoverCompleteBase<TValue> : BootstrapInputBase<TValue>,
155149
/// </summary>
156150
protected string? PlacementString => Placement == Placement.Auto ? null : Placement.ToDescriptionString();
157151

158-
/// <summary>
159-
/// 获得 获得焦点自动显示下拉框设置字符串
160-
/// </summary>
161-
protected string? ShowDropdownListOnFocusString => ShowDropdownListOnFocus ? null : "false";
162-
163152
/// <summary>
164153
/// 获得 CustomClass 字符串
165154
/// </summary>

0 commit comments

Comments
 (0)