Skip to content

Use store-widget for the Store panel's widget zones - #994

Merged
KrzysztofPajak merged 4 commits into
developfrom
fix/store-panel-widget-tags
Oct 25, 2026
Merged

KrzysztofPajak merged 4 commits into
developfrom
fix/store-panel-widget-tags

Conversation

@KrzysztofPajak

Copy link
Copy Markdown
Member

Type: bugfix

Stacked on #993: the new test also covers the <vc:widget> tags that #993 fixes in the Nordic theme. Merge #993 first. This PR then retargets to develop.

Issue

Eight views in the Store owner panel (Grand.Web.Store) were copied from the Admin and Vendor panels and still use <vc:admin-widget> (11 tags) or <vc:vendor-widget> (2 tags). Razor generates a <vc:...> tag helper only for the view components of assemblies that the view registers with @addTagHelper. Grand.Web.Store registers its own assembly and Grand.Web.Common, and it does not reference Grand.Web.Admin or Grand.Web.Vendor. The compiled Grand.Web.Store.dll contains tag helpers only for store-widget, store-page and the two bestseller reports. The 13 tags therefore reach the browser as empty unknown elements, so these widget zones never render a widget in the Store panel:

  • Category/List.cshtml (category_list_buttons)
  • Category/Partials/CreateOrUpdate.TabInfo.cshtml
  • Product/List.cshtml (product_list_buttons)
  • ProductAttributeCombination/AttributeCombinationPopup.cshtml (product_details_attribute_combination_buttons)
  • Setting/Partials/Sales.TabLoyaltyPoints.cshtml
  • Setting/Partials/Sales.TabShoppingCart.cshtml
  • Shared/Partials/UserFields.cshtml
  • Home/AccessDenied.cshtml (store_security_access_denied_top / _bottom, via vendor-widget)

Razor reports no error or warning for a <vc:...> tag it cannot resolve, which is how these and the Nordic theme's tags (#993) went unnoticed.

Solution

  • The 13 tags become <vc:store-widget>. StoreWidgetViewComponent takes the same widgetZone and additionalData, and the zone names are unchanged.
  • New test Grand.Modules.Tests/Views/ViewComponentTagTests. For every <vc:...> in a .cshtml under src, it finds the view component by class name or [ViewComponent(Name = ...)] and the project that declares it. It then checks that the _ViewImports.cshtml chain of the project compiling the view registers that assembly with @addTagHelper. A second test pins the scan to known components, so a broken scan cannot pass silently.

Without this fix, the test fails and lists exactly the 8 files above. With the fix, it passes.

Breaking changes

None. Plugins that render in these zones now appear in the Store panel as well as in Admin, as the views intended.

Testing

  1. dotnet test src/Tests/Grand.Modules.Tests --filter ViewComponentTagTests passes.
  2. Change one of the edited tags back to <vc:admin-widget> and rerun the test. It fails and names that file.
  3. Run the app and sign in as a store manager. Open Catalog → Products and Catalog → Categories in the Store panel, then view the page source: it contains no <vc: elements.

support added 3 commits October 25, 2026 12:19
#922 dropped the theme's reference to Grand.Web and its
`@addTagHelper *, Grand.Web`, so `<vc:...>` tags for components that
live in Grand.Web stopped compiling into tag helpers. Razor emitted
them as unknown HTML elements: the productdetails_* widget zones and
the also-purchased/related/similar/recommended sections never ran, and
the empty <vc:widget> elements took a full row inside .nordic-pd__main,
pushing the product overview below the gallery.

Component.InvokeAsync resolves the component at runtime, as the rest
of the theme already does, so the theme keeps depending only on
Grand.Web.Models.
…themes

#922 removed `@addTagHelper *, Grand.Web` from plugin and theme
_ViewImports and made a plugin reference to Grand.Web a build error.
View-component tag helpers are generated per registered assembly, so
<vc:widget> in any theme or plugin view compiled to a literal unknown
element: its widget zones rendered nothing, with no build error.

Every plugin and theme registers Grand.Web.Common, which is also an
application part of the host, so the component works there for all of
them. WidgetModel keeps its Grand.Web.Models.Cms namespace, which
storefront and theme _ViewImports import, and the cache key moves to
CacheKey. Nordic's widget zones go back to <vc:widget>; the product-list
components still live in Grand.Web and stay invoked by name.
Eight Store panel views, copied from the Admin and Vendor panels, kept
<vc:admin-widget> and <vc:vendor-widget>. Grand.Web.Store registers
only its own assembly and Grand.Web.Common with @addTagHelper, so those
tags compiled to literal unknown elements and the zones rendered no
widgets. StoreWidget takes the same widgetZone and additionalData.

ViewComponentTagTests checks every <vc:...> in the repository against
the assemblies its view registers, since Razor reports no error for a
tag it cannot resolve.
Base automatically changed from fix/nordic-product-view-components to develop October 25, 2026 13:39
[TestClass]
public class ViewComponentTagTests
{
private static readonly string Src = Path.Combine(Installer.RepositoryPaths.Root, "src");
var assemblies = new HashSet<string>();
for (var dir = Path.GetDirectoryName(view); dir != null && dir.Length >= projectDir.Length; dir = Path.GetDirectoryName(dir))
{
var imports = Path.Combine(dir, "_ViewImports.cshtml");
@KrzysztofPajak
KrzysztofPajak merged commit 195e0af into develop Oct 25, 2026
9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the fix/store-panel-widget-tags branch October 25, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant