mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-04 04:58:05 +08:00
fix(module: select): do not bring up keyboard when EnableSearch is false (#1992)
* fix(module:select): do not bring up keyboard when EnableSearch is false * Update SelectContent.razor * consider tags mode as searchEnabled
This commit is contained in:
parent
c9c628070d
commit
bd8ecd9773
@ -754,7 +754,7 @@ namespace AntDesign
|
||||
.If($"{ClassPrefix}-lg", () => Size == AntSizeLDSType.Large)
|
||||
.If($"{ClassPrefix}-borderless", () => !Bordered)
|
||||
.If($"{ClassPrefix}-show-arrow", () => ShowArrowIcon)
|
||||
.If($"{ClassPrefix}-show-search", () => EnableSearch || SelectMode == SelectMode.Tags)
|
||||
.If($"{ClassPrefix}-show-search", () => IsSearchEnabled)
|
||||
.If($"{ClassPrefix}-bordered", () => Bordered)
|
||||
.If($"{ClassPrefix}-loading", () => Loading)
|
||||
.If($"{ClassPrefix}-disabled", () => Disabled)
|
||||
@ -1715,7 +1715,7 @@ namespace AntDesign
|
||||
}
|
||||
|
||||
if (key == "BACKSPACE" && string.IsNullOrEmpty(_searchValue) &&
|
||||
(EnableSearch || SelectMode == SelectMode.Tags || AllowClear))
|
||||
(IsSearchEnabled || AllowClear))
|
||||
{
|
||||
if (string.IsNullOrEmpty(_prevSearchValue) && SelectedOptionItems.Count > 0)
|
||||
await OnRemoveSelectedAsync(SelectedOptionItems.Last());
|
||||
|
@ -260,10 +260,10 @@ namespace AntDesign
|
||||
internal bool HasValue => SelectOptionItems.Any(x => x.IsSelected);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the value of EnableSearch parameter
|
||||
/// Returns whether the user can input a pattern to search matched items
|
||||
/// </summary>
|
||||
/// <returns>true if search is enabled</returns>
|
||||
internal bool IsSearchEnabled => EnableSearch;
|
||||
internal bool IsSearchEnabled => EnableSearch || SelectMode == SelectMode.Tags;
|
||||
|
||||
/// <summary>
|
||||
/// Sorted list of SelectOptionItems
|
||||
@ -680,7 +680,7 @@ namespace AntDesign
|
||||
}
|
||||
}
|
||||
|
||||
if (EnableSearch || SelectMode == SelectMode.Tags)
|
||||
if (IsSearchEnabled)
|
||||
{
|
||||
await SetInputFocusAsync();
|
||||
}
|
||||
|
@ -14,23 +14,24 @@
|
||||
}
|
||||
<span class="@Prefix-selection-search" style="@_inputWidth">
|
||||
<input @ref="ParentSelect._inputRef"
|
||||
@oninput="OnInput"
|
||||
@onkeyup="OnKeyUp"
|
||||
@onkeydown="OnKeyDown"
|
||||
@attributes=@AdditonalAttributes()
|
||||
@onkeypress="@OnKeyPressEventHandler"
|
||||
@onkeypress:preventDefault="@_suppressInput"
|
||||
@onkeypress:stopPropagation="true"
|
||||
@bind-value="@SearchValue"
|
||||
id="@ParentSelect.Id"
|
||||
role="combobox"
|
||||
class="@Prefix-selection-search-input"
|
||||
autocomplete="off"
|
||||
aria-owns="@(ParentSelect.Id)_list"
|
||||
aria-expanded="@IsOverlayShow"
|
||||
aria-autocomplete="list"
|
||||
aria-controls="@(ParentSelect.Id)_list"
|
||||
style="@_inputStyle"/>
|
||||
@oninput="OnInput"
|
||||
@onkeyup="OnKeyUp"
|
||||
@onkeydown="OnKeyDown"
|
||||
@attributes=@AdditonalAttributes()
|
||||
@bind-value="@SearchValue"
|
||||
id="@ParentSelect.Id"
|
||||
type="search"
|
||||
readonly="@(!ParentSelect.IsSearchEnabled)"
|
||||
unselectable="@(ParentSelect.IsSearchEnabled ? false : "on")"
|
||||
role="combobox"
|
||||
class="@Prefix-selection-search-input"
|
||||
autocomplete="off"
|
||||
aria-owns="@(ParentSelect.Id)_list"
|
||||
aria-expanded="@IsOverlayShow"
|
||||
aria-autocomplete="list"
|
||||
aria-controls="@(ParentSelect.Id)_list"
|
||||
aria-haspopup="listbox"
|
||||
style="@_inputStyle"/>
|
||||
</span>
|
||||
@if (ShowPlaceholder)
|
||||
{
|
||||
@ -248,23 +249,24 @@ else //ParentSelect.SelectMode != SelectMode.Default
|
||||
<div class="@Prefix-selection-overflow-item @Prefix-selection-overflow-item-suffix" style="opacity: 1; order: @(ParentSelect.IsResponsive?_calculatedMaxCount-1:ParentSelect.SelectedOptionItems.Count)">
|
||||
<div class="@Prefix-selection-search" style="@_inputWidth">
|
||||
<input @ref="ParentSelect._inputRef"
|
||||
@oninput="OnInput"
|
||||
@onkeyup="OnKeyUp"
|
||||
@onkeydown="OnKeyDown"
|
||||
@attributes=@AdditonalAttributes()
|
||||
@onkeypress="@OnKeyPressEventHandler"
|
||||
@onkeypress:preventDefault="@_suppressInput"
|
||||
@onkeypress:stopPropagation="true"
|
||||
@bind-value="@SearchValue"
|
||||
id="@ParentSelect.Id"
|
||||
role="combobox"
|
||||
class="@Prefix-selection-search-input"
|
||||
autocomplete="off"
|
||||
aria-owns="@(ParentSelect.Id)_list"
|
||||
aria-expanded="@IsOverlayShow"
|
||||
aria-autocomplete="list"
|
||||
aria-controls="@(ParentSelect.Id)_list"
|
||||
style="@_inputStyle"/>
|
||||
@oninput="OnInput"
|
||||
@onkeyup="OnKeyUp"
|
||||
@onkeydown="OnKeyDown"
|
||||
@attributes=@AdditonalAttributes()
|
||||
@bind-value="@SearchValue"
|
||||
id="@ParentSelect.Id"
|
||||
type="search"
|
||||
readonly="@(!ParentSelect.IsSearchEnabled)"
|
||||
unselectable="@(ParentSelect.IsSearchEnabled ? false : "on")"
|
||||
role="combobox"
|
||||
class="@Prefix-selection-search-input"
|
||||
autocomplete="off"
|
||||
aria-owns="@(ParentSelect.Id)_list"
|
||||
aria-expanded="@IsOverlayShow"
|
||||
aria-autocomplete="list"
|
||||
aria-controls="@(ParentSelect.Id)_list"
|
||||
aria-haspopup="listbox"
|
||||
style="@_inputStyle"/>
|
||||
<span class="@Prefix-selection-search-mirror" aria-hidden="true"> </span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -106,7 +106,7 @@ namespace AntDesign.Select.Internal
|
||||
SetSuppressInput();
|
||||
if (firstRender)
|
||||
{
|
||||
if (ParentSelect.EnableSearch)
|
||||
if (ParentSelect.IsSearchEnabled)
|
||||
{
|
||||
DomEventListener.AddShared<JsonElement>("window", "beforeunload", Reloading);
|
||||
await Js.InvokeVoidAsync(JSInteropConstants.AddPreventKeys, ParentSelect._inputRef, new[] { "ArrowUp", "ArrowDown" });
|
||||
@ -270,7 +270,7 @@ namespace AntDesign.Select.Internal
|
||||
if (!_suppressInput)
|
||||
{
|
||||
_suppressInput = true;
|
||||
_inputStyle = "caret-color: transparent;";
|
||||
_inputStyle = "opacity: 0;";
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -308,16 +308,6 @@ namespace AntDesign.Select.Internal
|
||||
return label;
|
||||
}
|
||||
|
||||
protected void OnKeyPressEventHandler(KeyboardEventArgs _)
|
||||
{
|
||||
if (!ParentSelect.IsSearchEnabled)
|
||||
SearchValue = string.Empty;
|
||||
else if (ParentSelect.IsResponsive)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<string, object> AdditonalAttributes()
|
||||
{
|
||||
var dict = new Dictionary<string, object>();
|
||||
|
Loading…
Reference in New Issue
Block a user