From fdc6c4e0e8f8b79be5c08fa79829790d982ab0a2 Mon Sep 17 00:00:00 2001 From: Engincan VESKE <43685404+EngincanV@users.noreply.github.com> Date: Mon, 21 Aug 2023 17:42:39 +0300 Subject: [PATCH] Fix layout hooks filtering and show layout hooks for the specified layouts --- .../Components/LayoutHooks/LayoutHook.razor.cs | 2 +- .../Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs index f5ce191f20..f51223dcd5 100644 --- a/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Components/LayoutHooks/LayoutHook.razor.cs @@ -26,7 +26,7 @@ public partial class LayoutHook : ComponentBase { layoutHooks = layoutHooks .Where(IsComponentBase) - .WhereIf(string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout) + .WhereIf(!string.IsNullOrWhiteSpace(Layout), x => x.Layout == Layout) .ToList(); } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs index 082ca59ee0..562f3151e9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/LayoutHookViewComponent.cs @@ -18,8 +18,10 @@ public class LayoutHookViewComponent : AbpViewComponent public virtual IViewComponentResult Invoke(string name, string layout) { - var hooks = Options.Hooks.GetOrDefault(name)?.Where(x => x.Layout == layout && IsViewComponent(x)).ToArray() - ?? Array.Empty(); + var hooks = Options.Hooks.GetOrDefault(name)? + .Where(IsViewComponent) + .WhereIf(!string.IsNullOrWhiteSpace(layout), x => x.Layout == layout) + .ToArray() ?? Array.Empty(); return View( "~/Volo/Abp/AspNetCore/Mvc/UI/Components/LayoutHook/Default.cshtml",