Skip to content

Commit a818622

Browse files
Merge pull request #157 from dxc-technology/fix-date-clickOutside
Fix date click outside
2 parents be000d0 + 274315e commit a818622

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@
7070
"ts-node": "7.0.0",
7171
"tslib": "^2.0.0",
7272
"tslint": "~6.1.0",
73-
"typescript": "^3.9.7"
73+
"typescript": "^3.6.5"
7474
}
7575
}

projects/dxc-ngx-cdk/src/lib/dxc-date/dxc-date.component.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,27 @@ export class DxcDateComponent implements OnChanges, OnInit {
153153

154154
@HostListener('document:click', ['$event'])
155155
public onClickOutsideHandler(event) {
156-
if (event.target.offsetParent !== null) {
156+
if (event.target.offsetParent !== null && event.target.offsetParent.getAttribute("class") !== null) {
157157
if(!event.target.offsetParent.getAttribute("class").includes('mde-popover-panel')
158158
&& !event.target.offsetParent.getAttribute("class").includes('mat-calendar-period')
159159
&& !event.target.offsetParent.getAttribute("class").includes('mat-calendar-table')){
160-
if (this._isCalendarOpened) {
161-
if (!this._isOpenClicked && !this._isSelectingDate) {
162-
this.closeCalendar();
163-
} else {
164-
this._isOpenClicked = false;
165-
this._isSelectingDate = false;
166-
}
167-
}
160+
this.checkOpenCalendar();
168161
}
169162
}
163+
else{
164+
this.checkOpenCalendar();
165+
}
166+
}
167+
168+
private checkOpenCalendar(){
169+
if (this._isCalendarOpened) {
170+
if (!this._isOpenClicked && !this._isSelectingDate) {
171+
this.closeCalendar();
172+
} else {
173+
this._isOpenClicked = false;
174+
this._isSelectingDate = false;
175+
}
176+
}
170177
}
171178

172179
public openCalendar(event: any) {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"outDir": "./dist/out-tsc",
66
"sourceMap": true,
77
"declaration": false,
8-
"module": "es2020",
8+
"module": "es2015",
99
"allowSyntheticDefaultImports": true,
1010
"moduleResolution": "node",
1111
"emitDecoratorMetadata": true,

0 commit comments

Comments
 (0)