From ef0b6903316c2a1253cdc2b8df3f62881b37f4a6 Mon Sep 17 00:00:00 2001 From: Andrzej Bakun Date: Thu, 26 Aug 2021 18:44:47 +0200 Subject: [PATCH] fix(module: autocomplete): overlay is showing for AutoCompleteSearch (#1860) * fix(module:autocomplete): overlay is showing for AutoCompleteSearch * translate comments * code cleanup Co-authored-by: ElderJames --- components/auto-complete/AutoComplete.razor | 18 ++++++++--------- .../auto-complete/AutoComplete.razor.cs | 20 +++++++++++++++++-- components/auto-complete/AutoCompleteInput.cs | 2 +- .../auto-complete/AutoCompleteSearch.cs | 8 ++++++-- 4 files changed, 34 insertions(+), 14 deletions(-) diff --git a/components/auto-complete/AutoComplete.razor b/components/auto-complete/AutoComplete.razor index 71b511a4..98b7bf4f 100644 --- a/components/auto-complete/AutoComplete.razor +++ b/components/auto-complete/AutoComplete.razor @@ -53,16 +53,16 @@ - @if (ChildContent == null) - { - - } - else - { - + + @if (ChildContent == null) + { + + } + else + { @ChildContent - - } + } + diff --git a/components/auto-complete/AutoComplete.razor.cs b/components/auto-complete/AutoComplete.razor.cs index f374cf7b..5f625a51 100644 --- a/components/auto-complete/AutoComplete.razor.cs +++ b/components/auto-complete/AutoComplete.razor.cs @@ -29,16 +29,19 @@ namespace AntDesign /// /// 列表对象集合 + /// List object collection /// private List AutoCompleteOptions { get; set; } = new List(); /// /// 列表数据集合 + /// List data collection /// private List> _optionDataItems = new List>(); /// /// 列表绑定数据源集合 + /// List bound data source collection /// private IEnumerable _options; @@ -58,6 +61,7 @@ namespace AntDesign /// /// 绑定列表数据项格式的数据源 + /// Bind the data source of the list data item format /// [Parameter] public IEnumerable> OptionDataItems @@ -89,36 +93,42 @@ namespace AntDesign /// /// 选项模板 + /// Option template /// [Parameter] public RenderFragment> OptionTemplate { get; set; } /// /// 格式化选项,可以自定义显示格式 + /// Formatting options, you can customize the display format /// [Parameter] public Func, string> OptionFormat { get; set; } /// /// 所有选项模板 + /// All option templates /// [Parameter] public RenderFragment OverlayTemplate { get; set; } /// /// 对比,用于两个对象比较是否相同 + /// Contrast, used to compare whether two objects are the same /// [Parameter] public Func CompareWith { get; set; } = (o1, o2) => o1?.ToString() == o2?.ToString(); /// /// 过滤表达式 + /// Filter expression /// [Parameter] public Func, string, bool> FilterExpression { get; set; } = (option, value) => string.IsNullOrEmpty(value) ? true : option.Label.Contains(value, StringComparison.InvariantCultureIgnoreCase); /// /// 允许过滤 + /// Allow filtering /// [Parameter] public bool AllowFilter { get; set; } = true; @@ -165,7 +175,7 @@ namespace AntDesign _inputComponent = input; } - #region 子控件触发事件 + #region 子控件触发事件 / Child controls trigger events public async Task InputFocus(FocusEventArgs e) { @@ -212,7 +222,7 @@ namespace AntDesign } } - #endregion 子控件触发事件 + #endregion 子控件触发事件 / Child controls trigger events protected override void OnParametersSet() { @@ -254,6 +264,7 @@ namespace AntDesign /// /// 打开面板 + /// Open panel /// public void OpenPanel() { @@ -270,6 +281,7 @@ namespace AntDesign /// /// 关闭面板 + /// Close panel /// public void ClosePanel() { @@ -289,6 +301,7 @@ namespace AntDesign } //设置高亮的对象 + //Set the highlighted object public void SetActiveItem(AutoCompleteOption item) { this.ActiveValue = item == null ? default(TOption) : item.Value; @@ -297,6 +310,7 @@ namespace AntDesign } //设置下一个激活 + //Set the next activation public void SetNextItemActive() { var opts = AutoCompleteOptions.Where(x => x.Disabled == false).ToList(); @@ -311,6 +325,7 @@ namespace AntDesign } //设置上一个激活 + //Set last activation public void SetPreviousItemActive() { var opts = AutoCompleteOptions.Where(x => x.Disabled == false).ToList(); @@ -331,6 +346,7 @@ namespace AntDesign if (items.Any(x => CompareWith(x.Value, this.ActiveValue)) == false) { // 如果当前激活项找在列表中不存在,那么我们需要做一些处理 + // If the current activation item does not exist in the list, then we need to do some processing if (items.Any(x => CompareWith(x.Value, this.SelectedValue))) { this.ActiveValue = this.SelectedValue; diff --git a/components/auto-complete/AutoCompleteInput.cs b/components/auto-complete/AutoCompleteInput.cs index 137ba533..ba9127b2 100644 --- a/components/auto-complete/AutoCompleteInput.cs +++ b/components/auto-complete/AutoCompleteInput.cs @@ -20,7 +20,7 @@ namespace AntDesign [CascadingParameter(Name = "OverlayTriggerContext")] public ForwardRef OverlayTriggerContext { - get { return RefBack; } + get => RefBack; set { RefBack = value; } } diff --git a/components/auto-complete/AutoCompleteSearch.cs b/components/auto-complete/AutoCompleteSearch.cs index dcf1188f..8bac83df 100644 --- a/components/auto-complete/AutoCompleteSearch.cs +++ b/components/auto-complete/AutoCompleteSearch.cs @@ -20,8 +20,12 @@ namespace AntDesign [CascadingParameter(Name = "OverlayTriggerContext")] public ForwardRef OverlayTriggerContext { - get { return WrapperRefBack; } - set { WrapperRefBack = value; } + get => RefBack; + set + { + WrapperRefBack = value; + RefBack = value; + } } protected override void OnInitialized()