Skip to content
This repository has been archived by the owner on Nov 16, 2021. It is now read-only.

clickOutside event is still registered from within ngIf #13

Closed
rpeelenconclusion opened this issue Jul 19, 2017 · 11 comments
Closed

clickOutside event is still registered from within ngIf #13

rpeelenconclusion opened this issue Jul 19, 2017 · 11 comments
Labels

Comments

@rpeelenconclusion
Copy link

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>
@arkon
Copy link
Owner

arkon commented Jul 19, 2017

attachOutsideOnClick might help here. I'll take a deeper look later though.

@alexandremoore
Copy link

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.

@arkon
Copy link
Owner

arkon commented Jul 20, 2017

Can you try using the [delayClickOutsideInit] option that I added in v2.4.0?

@arkon arkon added the bug label Jul 20, 2017
@rpeelenconclusion
Copy link
Author

Will try next week, I fixed it for now by adding an ID to the trigger and exclude that. Bit hacky, but it works

@alexandremoore
Copy link

I just tried using [delayClickOutsideInit] and now, the clickOutside event is no longer triggered.

@alexandremoore
Copy link

The workaround suggested by @rpeelenconclusion works for me as well.

@arkon
Copy link
Owner

arkon commented Jul 20, 2017

Whoops, made a dumb mistake. @alexandremoore Can you try it with v2.4.1?

@alexandremoore
Copy link

@arkon, it works with v2.4.1, thanks!

@NikolaJankovic
Copy link

NikolaJankovic commented Jan 2, 2018

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.

Example:

@OlegGranevskij
Copy link

Looks like this issue is still not resolved. I still have same problem with conditional element andclick event.

@kiknadze
Copy link

I found this solution and it works for me

<div class="video" (click)="isOpen = true; $event.stopPropagation()">

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

No branches or pull requests

6 participants