Skip to content

Commit

Permalink
fix(click): ensure click event always runs inside angular zone
Browse files Browse the repository at this point in the history
Fixes #961
Fixes #959
  • Loading branch information
mattlewis92 committed Apr 27, 2019
1 parent 91166ce commit de0d435
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions projects/angular-calendar/src/modules/common/click.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
Output,
EventEmitter,
Inject,
Input
Input,
NgZone
} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { Observable, Subject } from 'rxjs';
Expand All @@ -34,7 +35,8 @@ export class ClickDirective implements OnInit, OnDestroy {
constructor(
private renderer: Renderer2,
private elm: ElementRef<HTMLElement>,
@Inject(DOCUMENT) private document
@Inject(DOCUMENT) private document,
private zone: NgZone
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -64,7 +66,9 @@ export class ClickDirective implements OnInit, OnDestroy {
const isThisClickableElement =
this.elm.nativeElement === nearestClickableParent;
if (isThisClickableElement) {
this.click.next(event);
this.zone.run(() => {
this.click.next(event);
});
}
});
}
Expand Down

0 comments on commit de0d435

Please sign in to comment.