Repository navigation
Make <vc:widget> work in theme and plugin views again - #993
Merged
Merged
Conversation
#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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: bugfix
Issue
<vc:widget>stopped working in every theme and plugin view after #922. In the Nordic theme this is visible on any product page, e.g./ember-ceramic-pour-over-dripper: the product overview (name, price, add to cart) drops below the picture instead of sitting next to it.<vc:...>tags are tag helpers that Razor generates at compile time for the view components of every assembly registered with@addTagHelper.WidgetViewComponentlived inGrand.Web. #922 removed@addTagHelper *, Grand.Webfrom plugin and theme_ViewImportson the assumption thatGrand.Webhas no tag helpers, and it made a plugin reference toGrand.Weba build error (GRAND001). From then on, Razor emitted<vc:widget>in any plugin or theme view as a literal unknown HTML element, with no build error or warning:<vc:widget>in a theme stopped rendering its widgets. That is the form used throughout the default views, so any view copied from them into a theme is affected.<vc:widget>elements inside.nordic-pd__maingotwidth: 100%from Bootstrap's.row > *and pushed the overview column onto a new line.<vc:products-also-purchased>etc.).Solution
WidgetViewComponentmoves fromGrand.WebtoGrand.Web.Common. Every plugin and theme already registers@addTagHelper *, Grand.Web.Common, andGrand.Web.Commonis an application part of the host. As a result,<vc:widget>works again in all plugin and theme views without a reference toGrand.Web, and the host views keep working because they register both assemblies. The component's code is unchanged.WidgetModelmoves along with it. Its namespace staysGrand.Web.Models.Cms, as Move storefront view models into Grand.Web.Models #922 did for the other models. The storefront and theme_ViewImportsimport that namespace, andWidgetModelwas its only type.WIDGET_MODEL_KEYmoves fromCacheKeyConst(Grand.Web) toCacheKey(Grand.Infrastructure). The key string is unchanged and only the component uses it.Grand.Web.Common.Tests.ProductsAlsoPurchased,RelatedProducts,SimilarProducts,RecommendedProducts) depend onGrand.Webhandlers and cannot move. Nordic's Simple layout now invokes them by name withComponent.InvokeAsync, as its Grouped layout already did..ai/skills/theme-creation.mdexplains which<vc:...>tags work in a theme and how to rewrite the others.Breaking changes
WidgetViewComponentis nowGrand.Web.Common.Components.WidgetViewComponent(wasGrand.Web.Components). Views address it by name, so only code that references the type directly is affected.CacheKeyConst.WIDGET_MODEL_KEYis nowCacheKey.WIDGET_MODEL_KEY.Testing
GrandNode.slnxand run the storefront with the Nordic theme active./ember-ceramic-pour-over-dripper. The name, price and add-to-cart block sit to the right of the gallery, and the related products section appears below the tabs./cartand/login: none of them contains<vc:.productdetails_*zone (Nordic uses<vc:widget>there) and confirm that it appears on the product page.