Skip to content

Commit de0d435

Browse files
committed
fix(click): ensure click event always runs inside angular zone
Fixes #961 Fixes #959
1 parent 91166ce commit de0d435

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

projects/angular-calendar/src/modules/common/click.directive.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
Output,
88
EventEmitter,
99
Inject,
10-
Input
10+
Input,
11+
NgZone
1112
} from '@angular/core';
1213
import { DOCUMENT } from '@angular/common';
1314
import { Observable, Subject } from 'rxjs';
@@ -34,7 +35,8 @@ export class ClickDirective implements OnInit, OnDestroy {
3435
constructor(
3536
private renderer: Renderer2,
3637
private elm: ElementRef<HTMLElement>,
37-
@Inject(DOCUMENT) private document
38+
@Inject(DOCUMENT) private document,
39+
private zone: NgZone
3840
) {}
3941

4042
ngOnInit(): void {
@@ -64,7 +66,9 @@ export class ClickDirective implements OnInit, OnDestroy {
6466
const isThisClickableElement =
6567
this.elm.nativeElement === nearestClickableParent;
6668
if (isThisClickableElement) {
67-
this.click.next(event);
69+
this.zone.run(() => {
70+
this.click.next(event);
71+
});
6872
}
6973
});
7074
}

0 commit comments

Comments
 (0)