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

Destroy hook of agm-direction directive fails on back browser button click #66

Closed
vleput opened this issue May 6, 2019 · 1 comment · Fixed by #69
Closed

Destroy hook of agm-direction directive fails on back browser button click #66

vleput opened this issue May 6, 2019 · 1 comment · Fixed by #69
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@vleput
Copy link

vleput commented May 6, 2019

Issue description

My app crashes and getting a weird error message in the console from the agm-direction library when hitting the "back" button of the browser (only tested in Chrome).
My map is in a lazy-loaded module, and all agm-* related components are in a single component that is in that lazy-loaded module.
Below is the message in the console:

TypeError: Cannot read property 'setPanel' of undefined
    at AgmDirection.push../node_modules/agm-direction/fesm5/agm-direction.js.AgmDirection.removeDirections (agm-direction.js:306)
    at AgmDirection.push../node_modules/agm-direction/fesm5/agm-direction.js.AgmDirection.ngOnDestroy (agm-direction.js:100)
    at callProviderLifecycles (core.js:18860)

It seems like directionsDisplay is undefined when running the ngOnDestroy hook of the agm-direction directive?

Steps to reproduce the issue

  1. Navigate to Angular app, home route
  2. Click on a /map route that loads a lazy-loaded module containing the agm-direction directive
  3. Click on the back button of the browser
  4. App crashes: component disappears from DOM, route stays the same, and the error message above is logged in the console

What's the expected result?

  • agm-direction directive destroys itself gracefully

What's the actual result?

  • There seems to be a bug in the ngOnDestroy hook of the agm-direction component
@vleput vleput changed the title Destroy hook of agm-direction component fails on back browser button click Destroy hook of agm-direction directive fails on back browser button click May 6, 2019
@vleput
Copy link
Author

vleput commented May 6, 2019

The map part of the app I inherited is pretty buggy so might be why I'm getting this. Still might be nice to check whether directionsDisplay https://github.com/explooosion/Agm-Direction/blob/master/src/directive/agm-direction.directive.ts#L54 is not undefined on the destroy hook

@explooosion explooosion added the help wanted Indicates that a maintainer wants help on an issue or pull request label May 24, 2019
@explooosion explooosion mentioned this issue May 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants