Skip to content

Commit

Permalink
fix: fixed datetime picker global listener (#793)
Browse files Browse the repository at this point in the history
* fixed the datetime picker global listener

* also fix datepicker
  • Loading branch information
MattL75 committed May 10, 2019
1 parent a33dfc2 commit eeab56c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
7 changes: 3 additions & 4 deletions library/src/lib/date-picker/date-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ export class DatePickerComponent implements OnInit, OnDestroy, ControlValueAcces
this.closeCalendar();
}

@HostListener('document:click', ['$event.path'])
public onGlobalClick(targetElementPath: Array<any>) {
const elementRefInPath = targetElementPath.find(e => e === this.eRef.nativeElement);
if (!elementRefInPath) {
@HostListener('document:click', ['$event'])
public onGlobalClick(event: MouseEvent) {
if (!this.eRef.nativeElement.contains(event.target)) {
this.closeCalendar();
}
}
Expand Down
7 changes: 3 additions & 4 deletions library/src/lib/datetime-picker/datetime-picker.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,9 @@ export class DatetimePickerComponent implements OnInit, OnDestroy, ControlValueA
}

/** @hidden */
@HostListener('document:click', ['$event.path'])
public onGlobalClick(targetElementPath: Array<any>): void {
const elementRefInPath = targetElementPath.find(e => e === this.elRef.nativeElement);
if (!elementRefInPath) {
@HostListener('document:click', ['$event'])
public onGlobalClick(event: MouseEvent): void {
if (!this.elRef.nativeElement.contains(event.target)) {
this.closePopover();
}
}
Expand Down

0 comments on commit eeab56c

Please sign in to comment.