Skip to content

Commit

Permalink
Merge pull request #157 from dxc-technology/fix-date-clickOutside
Browse files Browse the repository at this point in the history
Fix date click outside
  • Loading branch information
mawelCaballero authored Nov 9, 2020
2 parents be000d0 + 274315e commit a818622
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@
"ts-node": "7.0.0",
"tslib": "^2.0.0",
"tslint": "~6.1.0",
"typescript": "^3.9.7"
"typescript": "^3.6.5"
}
}
25 changes: 16 additions & 9 deletions projects/dxc-ngx-cdk/src/lib/dxc-date/dxc-date.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,20 +153,27 @@ export class DxcDateComponent implements OnChanges, OnInit {

@HostListener('document:click', ['$event'])
public onClickOutsideHandler(event) {
if (event.target.offsetParent !== null) {
if (event.target.offsetParent !== null && event.target.offsetParent.getAttribute("class") !== null) {
if(!event.target.offsetParent.getAttribute("class").includes('mde-popover-panel')
&& !event.target.offsetParent.getAttribute("class").includes('mat-calendar-period')
&& !event.target.offsetParent.getAttribute("class").includes('mat-calendar-table')){
if (this._isCalendarOpened) {
if (!this._isOpenClicked && !this._isSelectingDate) {
this.closeCalendar();
} else {
this._isOpenClicked = false;
this._isSelectingDate = false;
}
}
this.checkOpenCalendar();
}
}
else{
this.checkOpenCalendar();
}
}

private checkOpenCalendar(){
if (this._isCalendarOpened) {
if (!this._isOpenClicked && !this._isSelectingDate) {
this.closeCalendar();
} else {
this._isOpenClicked = false;
this._isSelectingDate = false;
}
}
}

public openCalendar(event: any) {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2020",
"module": "es2015",
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
Expand Down

0 comments on commit a818622

Please sign in to comment.