!3609 fix(#I65MRC): do not update Value when input value on search box on Select component

* Merge branch 'main' into fix/select
* fix: 修复 Select 下拉框输入搜索条件时 Value 直接改变问题
This commit is contained in:
Argo 2022-12-10 16:11:51 +00:00
parent 9b153e4330
commit d9d8ce996d

View File

@ -163,22 +163,22 @@ public partial class Select<TValue> : ISelect
{
DataSource = Items.ToList();
DataSource.AddRange(Children);
SelectedItem = DataSource.FirstOrDefault(i => i.Value.Equals(CurrentValueAsString, StringComparison))
?? DataSource.FirstOrDefault(i => i.Active)
?? DataSource.FirstOrDefault();
// 检查 Value 值是否在候选项中存在
// Value 不等于 选中值即不存在
if (!string.IsNullOrEmpty(SelectedItem?.Value) && CurrentValueAsString != SelectedItem.Value)
{
_ = ItemChanged(SelectedItem);
}
}
else
{
DataSource = OnSearchTextChanged(SearchText).ToList();
}
SelectedItem = DataSource.FirstOrDefault(i => i.Value.Equals(CurrentValueAsString, StringComparison))
?? DataSource.FirstOrDefault(i => i.Active)
?? DataSource.FirstOrDefault();
// 检查 Value 值是否在候选项中存在
// Value 不等于 选中值即不存在
if (!string.IsNullOrEmpty(SelectedItem?.Value) && CurrentValueAsString != SelectedItem.Value)
{
_ = ItemChanged(SelectedItem);
}
}
/// <summary>