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

go-header-bar component does not display its contents when navigated to the same component. #571

Closed
sudheepdivakargithub opened this issue Jun 3, 2020 · 7 comments
Labels
bug Something isn't working new issue This issue has yet to receive attention

Comments

@sudheepdivakargithub
Copy link
Contributor

Describe the bug
When the app navigates to the same component, the go-header-bar component does not display its content.

To Reproduce
Steps to reproduce the behavior:

  1. Get a template rendered in the go-header-bar component.'
  2. On any event navigate to the same component.
  3. Observe that the go-header=bar is blank.

Expected behavior
go-header-bar should display the content supplied.

Screenshots
If applicable, add screenshots to help explain your problem.

@sudheepdivakargithub sudheepdivakargithub added bug Something isn't working new issue This issue has yet to receive attention labels Jun 3, 2020
@grahamhency
Copy link
Contributor

Hey @sudheepdivakargithub, in Angular when a navigation event is fired that targets the same route that is active, Angular will not re-render the component by default. I am curious what could be causing this. Can you provide any code examples that could explain why this might be happening in your case?

@sudheepdivakargithub
Copy link
Contributor Author

sudheepdivakargithub commented Jun 5, 2020

Hi Graham, please refer https://stackblitz.com/edit/angular-ivy-dfgmuq to reproduce this issue.

  1. Wait for the app to load and notice that the go-header-bar is visible.
  2. Click on Step 1. App navigates to another route.
  3. Click on Step 2. Observe that the g-header-bar is not visible.

One thing to note is in the template with goHeaderBar directive we render buttons dynamically.

@grahamhency
Copy link
Contributor

Thanks for that replication @sudheepdivakargithub! That helped. I removed a bunch of stuff from the stackblitz just to get to the base issue, but I believe it has something to do with how the goHeaderBar directive is handled when it get's destroyed.

Because of the way routing is being used here Angular will trigger a page refresh for the component, even though it's the same component being used and just a different param. This probably doesn't need to happen and I've been able to create a work-around until we can find a resolution to this bug.

For the buttons that perform the routing in the header-bar, try using this for routing:

fireActionEvent() {
  this.router
    .navigateByUrl('/', { skipLocationChange: true })
    .then(() => {
      this.router.navigate(['detail', 200])
    });
}

Instead of:

fireActionEvent() {
  this.router.navigate(["detail", "200"]);
}

@grahamhency
Copy link
Contributor

@sudheepdivakargithub here is the fork of your recreation with a working example: https://stackblitz.com/edit/goponents-header-bar-disappearing

@grahamhency
Copy link
Contributor

@sudheepdivakargithub I figured out why this was happening in Goponents, although I am not sure of a way to actually bypass this. If we remove this line the previous page's header-bar would appear on the next page, even if that page didn't have a header-bar declared. I'll need to think on this.

The issue:

@grahamhency
Copy link
Contributor

@sudheepdivakargithub, did this fork solve your issue?

@sudheepdivakargithub here is the fork of your recreation with a working example: https://stackblitz.com/edit/goponents-header-bar-disappearing

Doing this:

this.router
      .navigateByUrl('/', { skipLocationChange: true })
      .then(() => {
        this.router.navigate(['detail', 200])
      });

Instead of this:

this.router.navigate(["/detail", 100]);

@StevenUlmer
Copy link
Contributor

Closing this issue as it was fixed as a part of #581

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new issue This issue has yet to receive attention
Projects
None yet
Development

No branches or pull requests

3 participants