Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error routing when import CatalogModule - Vendure 2.1.0 #2455

Closed
hieundtlu opened this issue Oct 16, 2023 · 3 comments
Closed

Error routing when import CatalogModule - Vendure 2.1.0 #2455

hieundtlu opened this issue Oct 16, 2023 · 3 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@hieundtlu
Copy link

hieundtlu commented Oct 16, 2023

Describe the bug
I would like to reuse components such as AssetsComponent. As for issue #1357 we could reuse it on version 1.x.x, but on version 2 you added logic on the constructor of CatalogModule (pageService.registerPageTab(...)) and I got an error Error: A page with the tab "catalog.products" has already been registered when I try navigate to Products.

image

Reproduce

  • Create new plugin
  • Create component and import CatalogModule to reuse AssetComponent
@Component({
    selector: 'blog-detail',
    templateUrl: './blog-detail.component.html',
    styleUrls: ['./blog-detail.component.scss'],
    changeDetection: ChangeDetectionStrategy.Default,
    standalone: true,
    imports: [SharedModule, CatalogModule],
})
export class BlogDetailComponent {}
  • Go to new page then navigate to any route on Catalog, you will get the error above!

Have you had any solution to solve this issue? Thank you a lot!

Environment (please complete the following information):

  • @vendure/core version: 2.1.0
@hieundtlu hieundtlu added the type: bug 🐛 Something isn't working label Oct 16, 2023
@michaelbromley
Copy link
Member

Possible work-around (not tried this, it just came to me as an idea to try):

Create an NgModule, add the AssetsComponent to the declarations array, import SharedModule in the imports, and then import that new NgModule into your component's imports array.

@hieundtlu
Copy link
Author

I tried your idea, but got an error Cannot declare 'AssetsComponent' in an NgModule as it's not a part of the current compilation.. Angular just allows to import module.

image

@michaelbromley
Copy link
Member

I added a check to prevent these the constructor logic from running twice. Will be available in the next patch (2.1.3)

@michaelbromley michaelbromley moved this from 🏗 In progress to ✅ Done in Vendure OS Roadmap Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
Status: 🚀 Shipped
Development

No branches or pull requests

2 participants