mirror of
https://gitee.com/LongbowEnterprise/BootstrapBlazor.git
synced 2024-11-29 18:49:08 +08:00
fix(Cascader): not pop dropdown menu after update IsDisable to false (#4257)
* refactor: 更正单词拼写错误 * refactor: 修复禁用后无法弹出问题 * chore: bump version 8.9.2-beta05
This commit is contained in:
parent
4dc4e05460
commit
6f02ab0fe7
@ -1,7 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Razor">
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>8.9.2-beta04</Version>
|
||||
<Version>8.9.2-beta05</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
|
||||
|
@ -9,29 +9,26 @@
|
||||
<div @attributes="AdditionalAttributes" id="@Id" class="@ClassString" tabindex="-1">
|
||||
<input type="text" id="@InputId" readonly disabled="@Disabled" class="@InputClassName" data-bs-toggle="dropdown" placeholder="@PlaceHolder" value="@DisplayTextString" />
|
||||
<span class="@AppendClassName"><i class="@Icon"></i></span>
|
||||
@if (!IsDisabled)
|
||||
{
|
||||
<div class="dropdown-menu shadow">
|
||||
<CascadingValue Value="SelectedItems">
|
||||
@foreach (var item in Items)
|
||||
<div class="dropdown-menu shadow">
|
||||
<CascadingValue Value="SelectedItems">
|
||||
@foreach (var item in Items)
|
||||
{
|
||||
if (item.HasChildren)
|
||||
{
|
||||
if (item.HasChildren)
|
||||
{
|
||||
<div class="@ActiveItem("has-leaf dropdown-item", item)" data-val="@item.Value" @onclick="@(e => OnItemClick(item))">
|
||||
<span>@item.Text</span>
|
||||
<i class="@SubMenuIconString"></i>
|
||||
<ul class="nav sub-menu" @onclick:stopPropagation>
|
||||
<SubCascader Items="@item.Items" SubMenuIcon="@SubMenuIconString" OnClick="@OnItemClick" />
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="@ActiveItem("dropdown-item", item)" data-val="@item.Value" @onclick="@(e => OnItemClick(item))">@item.Text</div>
|
||||
}
|
||||
<div class="@ActiveItem("has-leaf dropdown-item", item)" data-val="@item.Value" @onclick="@(e => OnItemClick(item))">
|
||||
<span>@item.Text</span>
|
||||
<i class="@SubMenuIconString"></i>
|
||||
<ul class="nav sub-menu" @onclick:stopPropagation>
|
||||
<SubCascader Items="@item.Items" SubMenuIcon="@SubMenuIconString" OnClick="@OnItemClick" />
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
</CascadingValue>
|
||||
</div>
|
||||
<div class="dropdown-menu-arrow"></div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="@ActiveItem("dropdown-item", item)" data-val="@item.Value" @onclick="@(e => OnItemClick(item))">@item.Text</div>
|
||||
}
|
||||
}
|
||||
</CascadingValue>
|
||||
</div>
|
||||
<div class="dropdown-menu-arrow"></div>
|
||||
</div>
|
||||
|
@ -87,7 +87,7 @@ public partial class Cascader<TValue>
|
||||
[NotNull]
|
||||
private IIconTheme? IconTheme { get; set; }
|
||||
|
||||
private string _lastVaslue = string.Empty;
|
||||
private string _lastValue = string.Empty;
|
||||
|
||||
private string? SubMenuIconString => CssBuilder.Default("nav-link-right")
|
||||
.AddClass(SubMenuIcon, !string.IsNullOrEmpty(SubMenuIcon))
|
||||
@ -103,13 +103,13 @@ public partial class Cascader<TValue>
|
||||
Icon ??= IconTheme.GetIconByKey(ComponentIcons.CascaderIcon);
|
||||
SubMenuIcon ??= IconTheme.GetIconByKey(ComponentIcons.CascaderSubMenuIcon);
|
||||
|
||||
Items ??= Enumerable.Empty<CascaderItem>();
|
||||
Items ??= [];
|
||||
|
||||
PlaceHolder ??= Localizer[nameof(PlaceHolder)];
|
||||
|
||||
if (_lastVaslue != CurrentValueAsString)
|
||||
if (_lastValue != CurrentValueAsString)
|
||||
{
|
||||
_lastVaslue = CurrentValueAsString;
|
||||
_lastValue = CurrentValueAsString;
|
||||
SetDefaultValue(CurrentValueAsString);
|
||||
}
|
||||
}
|
||||
@ -139,7 +139,7 @@ public partial class Cascader<TValue>
|
||||
/// <param name="items"></param>
|
||||
/// <param name="value"></param>
|
||||
/// <returns></returns>
|
||||
private CascaderItem? GetNodeByValue(IEnumerable<CascaderItem> items, string value)
|
||||
private static CascaderItem? GetNodeByValue(IEnumerable<CascaderItem> items, string value)
|
||||
{
|
||||
foreach (var item in items)
|
||||
{
|
||||
@ -211,7 +211,7 @@ public partial class Cascader<TValue>
|
||||
CurrentValueAsString = value;
|
||||
if (OnSelectedItemChanged != null)
|
||||
{
|
||||
await OnSelectedItemChanged(SelectedItems.ToArray());
|
||||
await OnSelectedItemChanged([.. SelectedItems]);
|
||||
}
|
||||
if (SelectedItems.Count != 1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user