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

Breadcrumbs initial state is empty when chained in multiple router outlets #109

Closed
Vankerkom opened this issue Dec 16, 2021 · 12 comments
Closed
Labels
bug Something isn't working help wanted Extra attention is needed no-issue-activity

Comments

@Vankerkom
Copy link

Vankerkom commented Dec 16, 2021

🐞 Bug report

Description

The breadcrumbs do not initialize correctly when chained into multiple router outlets. The breadcrumbs show up after navigating to another page.

🔬 Minimal Reproduction

Create an application with the following structure:

  • Application Shell
    • Router Outlet
  • Feature Shell (Lazy loaded)
    • Router Outlet
  • Detailed Feature Shell
    • Breadcrumb Component
      • xng-breadcrumb

💻Your Environment

xng-breadcrumb@6.8.2
Angular Version: 12.1

🔥 Exception or Error

None.

@Vankerkom Vankerkom added the bug Something isn't working label Dec 16, 2021
@Vankerkom Vankerkom changed the title Breadcrumbs initial state is empty when chained in multiple router outlets. Breadcrumbs initial state is empty when chained in multiple router outlets Dec 16, 2021
@github-actions
Copy link

Hello 👋 @Vankerkom
Thank you for raising an issue. We will investigate into the issue and get back to you as soon as possible. Please make sure you have given us as much context as possible.
Feel free to raise a PR if you can fix the issue. Check the local development guide

@udayvunnam
Copy link
Owner

udayvunnam commented Dec 19, 2021

@Vankerkom can you please provide a reproducible example. Please use https://stackblitz.com/edit/angular-xng-breadcrumbs as reference

@udayvunnam udayvunnam added the need more info Further information requested label Feb 1, 2022
@TobiasXy
Copy link

TobiasXy commented Feb 8, 2022

For anyone who comes across this issue with a similar problem: I spend some time trying to create a reproducible example, because this happened on a project of mine too and it was super annoying.

Here it is: https://stackblitz.com/edit/angular-xng-breadcrumbs-ch2s2r?file=src%2Fapp%2Fapp.component.ts

What (apparently) was my problem:
I have an app with several layers of nested modules and a lots of lazy loaded routes. Take this structure for example (each entry is a module with corresponding component):

app
    main <-- this extra level seems important to reproduce the problem
        feature1
        feature2

The element is included in the "main" component, NOT in the "app" component.

When you open (or refresh) the page there is no breadcrumb shown. It only shows up once you click on "Feature2" and then it will stay even if you go back to Feature1. It's only missing on initial page load.

What solved it for me (and does as well in this example) is to require an instance of BreadcrumbService in AppComponent.
I guess this makes sure the service is instantiated early enough(?).

TL;DR:
Inject an instance of BreadcrumbService into the constructor of your AppComponent.

@udayvunnam
Copy link
Owner

Thank you @TobiasXy for the analysis and also for providing a fix from the application side.

If you know how to fix this in the library without having to inject in App component, please provide a fix as PR.

contribution guide
local development guide

@udayvunnam udayvunnam added help wanted Extra attention is needed and removed need more info Further information requested labels Feb 9, 2022
@stale
Copy link

stale bot commented Jun 10, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 10, 2022
@udayvunnam udayvunnam removed the wontfix This will not be worked on label Aug 3, 2022
@udayvunnam
Copy link
Owner

not stale

@stephencarvalho
Copy link

I'm having the same issue. Using version 6.8.3 on Angular 10. Apart from the work around fix mentioned has there been any other fix?

@stephencarvalho
Copy link

@TobiasXy could you share a code example of the fix you mentioned. Because I injected the breadcrumbService into my app.component.ts but I'm still getting the same issue.

When I initially load my application I do not see the breadcrumb but if I click on another page and comeback to the homepage then I can see the breadcrumbs

@stephencarvalho
Copy link

@udayvunnam Have there been any fixes for this issue?

@TobiasXy
Copy link

In february I wasn't able to set up the test suite, so unfortunately I couldn't provide a fix.
It didn't bother me anymore, because the workaround mentioned earlier works for me.
If I find some time I might look into it again, but can't promise it.

A code example (that also works in the stackblitz linked above) would be this code in your app.component.ts (or whatever your outermost component is called)

// ...
import { BreadcrumbService } from 'xng-breadcrumb';
// ...

export class AppComponent {

// ...
  constructor(breadcrumbService: BreadcrumbService /*, other parameters */) {
    //...
  }

// ....
}

@stale
Copy link

stale bot commented Feb 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Feb 18, 2023
@stale stale bot closed this as completed Jun 18, 2023
@udayvunnam udayvunnam reopened this Mar 17, 2024
@stale stale bot removed the wontfix This will not be worked on label Mar 17, 2024
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed no-issue-activity
Projects
None yet
Development

No branches or pull requests

4 participants