NbPopoverDirective lacks a null check for its NbOverlayRef in ngOnDestroy()
See original GitHub issueIssue type
I’m submitting a …
- bug report
- feature request
Issue description
Current behavior:
In our app, we have a stepper with some steps using popovers to give “extra” data. The popover works fine, but when we try to navigate away from the component, the page errors out on destroying the component, in particular the NbPopoverDirective used in the steps. This only started happening after we upgraded to v3.0.1.
Expected behavior:
Being able to navigate away from the page without issue. Other pages seem to work fine, it is only on the page with a stepper component.
Related code:
<nb-stepper>
[....]
<nb-step>
[....]
<i class="ion ion-help-circled"
[nbPopover]="'This is some string that we use in our program!'"
[nbPopoverMode]="'hint'"></i>
</nb-step>
</nb-stepper>
This is just an example of the code we use. Again, the popover works fine, it’s just when we try navigating away from the page, we get this error:
ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'dispose' of undefined
TypeError: Cannot read property 'dispose' of undefined
at NbPopoverDirective.push../node_modules/@nebular/theme/components/popover/popover.directive.js.NbPopoverDirective.ngOnDestroy (popover.directive.js:129)
at callProviderLifecycles (core.js:20988)
at callElementProvidersLifecycles (core.js:20956)
at callLifecycleHooksChildrenFirst (core.js:20946)
at destroyView (core.js:22008)
at callViewAction (core.js:22134)
at execComponentViewsAction (core.js:22056)
at destroyView (core.js:22007)
at callWithDebugContext (core.js:22767)
at Object.debugDestroyView [as destroyView] (core.js:22451)
This line points to here, and git history shows it was added without even checking this.ref
. This is odd, considering the rest of the file seems to do a null check for the ref. But, it seems like it’ll be an easy, almost-one-line fix:
- this.ref.dispose()
+ if (this.ref) {
+ this.ref.dispose();
+ }
Now I’m not so sure as to why the ref would be null in this instance, unless createOverlay()
is never called for popovers for some reason, or if when navigating away it destroys the ref first… Could be another issue to look into. Either way, a null check would be a great solution for now.
Other information:
npm, node, OS, Browser
Node, npm: 10.10.0, 6.4.1
OS: Windows 10
Browser: Both Firefox and Chrome
Angular, Nebular
Angular: 7.1.3
Nebular: 3.0.1
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:8
Top GitHub Comments
Guys, Happy New Year!🎄 And btw, the fix was released with 3.1.0.
I’m too waiting for the release - but for now I just
npm link
-ed the latestnebular
source.(Instructions here: https://github.com/akveo/nebular/blob/master/DEV_DOCS.md under the title
ngx-admin development on the latest Nebular sources
)