clickOutside event is still registered from within ngIf
rpeelenconclusion opened this issue · 11 comments
See code below. As soon as the click event is triggered on the video, the clickOutside event is triggered right after, closing it again. Not sure if it's a bug with angular or with this.
<div class="video"
(click)="isOpen = true">
<img src="assets/images/video-home.jpg"/>
<svg>
<use xlink:href="assets/svg/symbol-defs.svg#play-btn"></use>
</svg>
</div>
<div class="popup -video"
*ngIf="isOpen">
<div class="container">
<div class="content"
(clickOutside)="isOpen = false">
<span class="close" (click)="isOpen = false"></span>
<iframe width="560" height="315" src="https://www.youtube.com/embed/D2JPAnan13M?autoplay=1" frameborder="0" allowfullscreen>
</iframe>
</div>
</div>
</div>
attachOutsideOnClick
might help here. I'll take a deeper look later though.
I just had the same problem here. I also tried to put the (clickOutside) event inside a but same result, the event is always triggered right after.
Can you try using the [delayClickOutsideInit]
option that I added in v2.4.0?
Will try next week, I fixed it for now by adding an ID to the trigger and exclude that. Bit hacky, but it works
I just tried using [delayClickOutsideInit] and now, the clickOutside event is no longer triggered.
The workaround suggested by @rpeelenconclusion works for me as well.
Whoops, made a dumb mistake. @alexandremoore Can you try it with v2.4.1?
@arkon, it works with v2.4.1, thanks!
I'm having an issue with this, applying the [delayClickOutsideInit] property hasn't solved the issue.
<div (clickOutside)="inputOpen=false" [delayClickOutsideInit]="true" class="filter-input-container">
<div
(click)="inputOpen = !inputOpen"
[class]="inputOpen ? 'placeholder-container placeholder-container--selected' : 'placeholder-container'">
<span>Size</span>
</div>
<div *ngIf="inputOpen" class="values-container">
<div class="filter-checkbox" *ngFor="let size of sizesResolved" (click)="addSize(size)">
<div class="filter-checkbox--checked" *ngIf="activeSizes?.indexOf(size) > -1" >
<svg ... svg>
<span class="filter-checkbox__text">{{ size }}</span>
</div>
<div class="filter-checkbox--unchecked" *ngIf="activeSizes?.indexOf(size) == -1" >
<svg ... svg>
<span class="filter-checkbox__text">{{ size }}</span>
</div>
</div>
</div>
</div>
Clicking just outside of the conditional element works but anything inside of it incorrectly triggers the clickOutside event.
Looks like this issue is still not resolved. I still have same problem with conditional element andclick event.
I found this solution and it works for me
<div class="video" (click)="isOpen = true; $event.stopPropagation()">