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

popperTarget issue when used with element hidden by *ngIf (in Angular 8) #128

Open
dharmeshds opened this issue Dec 18, 2019 · 4 comments
Open

Comments

@dharmeshds
Copy link

Getting the error "Cannot set property 'referenceObject' of null" when loading the component because the element attached to popperTarget is conditionally hidden with *ngIf. Would anyone suggest an alternative or a fix please?

@ghost
Copy link

ghost commented Aug 4, 2020

I use the css property visibility to hide/show the element attached to the popper.

@tonysamperi
Copy link

@dharmeshds could you create a Blitz?
I just released my [email protected] which now uses Popper 2 and Angular 8...maybe I could handle this!

@ghost
Copy link

ghost commented Sep 16, 2020

HI, for the old version of the library you can wrap both the element attached to popperTarget and popper itself in the *ngIf.

it will be something like this:

<div *ngIf="condition" >
<div [popper]="myRefPopper" popperAppendTo="body"
               [popperTrigger]="'click'" [popperPlacement]="'bottom'">

</div>
<popper-content #myRefPopper>
<!-- here the content -->
</popper-content>
</div>

It works without error.

@tonysamperi
Copy link

tonysamperi commented Sep 16, 2020

image

I handled this scenario and now you can have an undefined ref, but of course it will show an empty popper...
So it's always better to hide everything.

Will release this in v 8.0.4...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants