From 6d074f538e2356391719a1feb84ef1bdedd1aede Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sat, 8 Oct 2022 20:17:11 +0800 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20hide=20?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wwwroot/modules/base/utility.js | 2 +- src/BootstrapBlazor/wwwroot/modules/menu.js | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/BootstrapBlazor/wwwroot/modules/base/utility.js b/src/BootstrapBlazor/wwwroot/modules/base/utility.js index 676d24c4d..b8ad23936 100644 --- a/src/BootstrapBlazor/wwwroot/modules/base/utility.js +++ b/src/BootstrapBlazor/wwwroot/modules/base/utility.js @@ -55,7 +55,7 @@ const getTargetElement = (element, selector = 'data-bs-target') => { return null } -const getTransitionDelayDurationFromElement = (element, delay = 20) => { +const getTransitionDelayDurationFromElement = (element, delay = 80) => { return getTransitionDurationFromElement(element) + delay } diff --git a/src/BootstrapBlazor/wwwroot/modules/menu.js b/src/BootstrapBlazor/wwwroot/modules/menu.js index 5e707dd87..94677b311 100644 --- a/src/BootstrapBlazor/wwwroot/modules/menu.js +++ b/src/BootstrapBlazor/wwwroot/modules/menu.js @@ -1,5 +1,5 @@ import BlazorComponent from "./base/blazor-component.js"; -import { getTargetElement } from "./base/utility.js" +import { getTargetElement, getTransitionDelayDurationFromElement } from "./base/utility.js" class Menu extends BlazorComponent { _init() { @@ -42,7 +42,7 @@ class Menu extends BlazorComponent { } } else { - this._disposeCollapse(collapse, target) + this._disposeCollapse(collapse, el) } } else { @@ -57,11 +57,17 @@ class Menu extends BlazorComponent { _disposeCollapse(collapse, target) { if (collapse._isShown()) { - collapse._element.classList.remove('show') - target.classList.remove('collapsed') - target.setAttribute('aria-expanded', 'false') + collapse.hide() + + const duration = getTransitionDelayDurationFromElement(target); + const handler = window.setTimeout(() => { + window.clearTimeout(handler) + collapse.dispose() + }, duration) + } + else { + collapse.dispose() } - collapse.dispose() } _dispose() { @@ -69,7 +75,7 @@ class Menu extends BlazorComponent { const target = getTargetElement(el) const collapse = bootstrap.Collapse.getInstance(target) if (collapse !== null) { - this._disposeCollapse(collapse, target) + this._disposeCollapse(collapse, el) } }) } -- Gitee From 7682a9f6d1cff9fbf43e62292102a70a62f458bc Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sat, 8 Oct 2022 20:26:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E4=BA=8C=E6=AC=A1=E8=8F=9C=E5=8D=95=E5=AF=BC=E8=87=B4=E6=94=B6?= =?UTF-8?q?=E7=BC=A9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Menu/Menu.razor.cs | 60 +++++++++++++------ 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/src/BootstrapBlazor/Components/Menu/Menu.razor.cs b/src/BootstrapBlazor/Components/Menu/Menu.razor.cs index 556e8f291..c05ad1dd5 100644 --- a/src/BootstrapBlazor/Components/Menu/Menu.razor.cs +++ b/src/BootstrapBlazor/Components/Menu/Menu.razor.cs @@ -33,6 +33,11 @@ public partial class Menu /// private MenuItem? ActiveMenu { get; set; } + /// + /// 是否需要调用 JS + /// + private bool InvokeJSInterop { get; set; } + /// /// 获得/设置 菜单数据集合 /// @@ -40,19 +45,43 @@ public partial class Menu [NotNull] public IEnumerable? Items { get; set; } + private bool _isAccordion; /// /// 获得/设置 是否为手风琴效果 默认为 false /// /// 启用此功能时 参数不生效 [Parameter] - public bool IsAccordion { get; set; } + public bool IsAccordion + { + get => _isAccordion; + set + { + if (_isAccordion != value) + { + _isAccordion = value; + InvokeJSInterop = true; + } + } + } + private bool _isExpanded; /// /// 获得/设置 是否全部展开 默认为 false /// /// 手风琴效果 时此参数不生效 [Parameter] - public bool IsExpandAll { get; set; } + public bool IsExpandAll + { + get => _isExpanded; + set + { + if (_isExpanded != value) + { + _isExpanded = value; + InvokeJSInterop = true; + } + } + } /// /// 获得/设置 侧栏是否收起 默认 false 未收起 @@ -109,7 +138,6 @@ public partial class Menu { base.OnInitialized(); - Items ??= Enumerable.Empty(); InitMenus(null, Items, Navigator.ToBaseRelativePath(Navigator.Uri)); if (!DisableNavigation) { @@ -119,16 +147,6 @@ public partial class Menu } } - /// - /// OnParametersSet 方法 - /// - protected override void OnParametersSet() - { - base.OnParametersSet(); - - Items ??= Enumerable.Empty(); - } - /// /// /// @@ -136,14 +154,18 @@ public partial class Menu /// protected override async Task ModuleInvokeVoidAsync(bool firstRender) { - if (firstRender) + if (IsVertical && Module != null) { - await base.ModuleInvokeVoidAsync(firstRender); - } - else if (Module != null) - { - await Module.InvokeVoidAsync("Menu.reset", Id); + if (firstRender) + { + await base.ModuleInvokeVoidAsync(firstRender); + } + else if (InvokeJSInterop) + { + await Module.InvokeVoidAsync("Menu.reset", Id); + } } + InvokeJSInterop = false; } private void InitMenus(MenuItem? parent, IEnumerable menus, string url) -- Gitee From 84e76247c762d381cdb37c53d90827d48c40c95e Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sat, 8 Oct 2022 20:36:02 +0800 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A9=BA=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E5=90=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/Components/Menu/Menu.razor.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BootstrapBlazor/Components/Menu/Menu.razor.cs b/src/BootstrapBlazor/Components/Menu/Menu.razor.cs index c05ad1dd5..5bd6411ca 100644 --- a/src/BootstrapBlazor/Components/Menu/Menu.razor.cs +++ b/src/BootstrapBlazor/Components/Menu/Menu.razor.cs @@ -138,6 +138,7 @@ public partial class Menu { base.OnInitialized(); + Items ??= Enumerable.Empty(); InitMenus(null, Items, Navigator.ToBaseRelativePath(Navigator.Uri)); if (!DisableNavigation) { -- Gitee From 60f73d833dc5186e859508251159417b65fdcd8a Mon Sep 17 00:00:00 2001 From: Argo-Lenovo Date: Sat, 8 Oct 2022 20:36:14 +0800 Subject: [PATCH 4/4] =?UTF-8?q?chore:=20=E5=8F=91=E5=B8=83=206.11.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BootstrapBlazor/BootstrapBlazor.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BootstrapBlazor/BootstrapBlazor.csproj b/src/BootstrapBlazor/BootstrapBlazor.csproj index 00bf5084c..5ccf48763 100644 --- a/src/BootstrapBlazor/BootstrapBlazor.csproj +++ b/src/BootstrapBlazor/BootstrapBlazor.csproj @@ -1,7 +1,7 @@ - 6.11.0 + 6.11.1 -- Gitee