Skip to content

Commit de5d99d

Browse files
authored
Merge pull request #172 from assureclaims/feature/RMA-101691
checkin on behalf of akshat
2 parents 994bc22 + c638807 commit de5d99d

File tree

2 files changed

+16
-36
lines changed

2 files changed

+16
-36
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
>
2525
<dxc-input-suffix-icon >
2626
<dxc-button id="help" [tabIndexValue]="disabled ? -1 : tabIndexValue" class="caln-btn" size="small" [ariaLabel]="ariaLabel" [ariaLabelledBy]="ariaLabelledBy" [ariaDescribedBy]="ariaDescribedBy" [border]="false"
27-
(onClick)="openCalendar()">
27+
(onClick)="openCalendar()" #calendarButton>
2828
<dxc-button-icon>
2929
<span class="icon-dxc-wrapper">
3030
<mat-icon class="mat-icon material-icons">calendar_today</mat-icon>

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

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ export class DxcDateComponent implements OnChanges, OnInit, ControlValueAccessor
140140
@ViewChild('calender', { read: ElementRef, static: false }) calender: ElementRef;
141141
@ViewChild(MdePopoverTrigger, { static: false })
142142
_dxcTrigger: MdePopoverTrigger;
143-
@ViewChild("dxcCalendar", { static: false })
144-
_dxcCalendar: MatCalendar<Moment>;
143+
@ViewChild("dxcCalendar", { static: false }) _dxcCalendar: MatCalendar<Moment>;
144+
@ViewChild('calendarButton', { read: ElementRef, static: false }) calendarButton: ElementRef;
145145

146146
private _sizes = ["medium", "large", "fillParent"];
147147

@@ -193,7 +193,7 @@ export class DxcDateComponent implements OnChanges, OnInit, ControlValueAccessor
193193
stringValue: value,
194194
dateValue: _dateValue.isValid() ? _dateValue.toDate() : null,
195195
};
196-
196+
197197
if (this.customOutput == true) {
198198
if (_dateReturn.dateValue instanceof Date) {
199199
this.value = this.datePipe.transform(_dateReturn.dateValue, this.format);
@@ -209,9 +209,9 @@ export class DxcDateComponent implements OnChanges, OnInit, ControlValueAccessor
209209
this.renderedValue = _dateReturn.stringValue;
210210
return false;
211211
}
212-
212+
213213
}
214-
else{
214+
else {
215215
this.value = value;
216216
this.dateValue = _dateValue;
217217
this.onChange.emit(_dateReturn);
@@ -259,35 +259,15 @@ export class DxcDateComponent implements OnChanges, OnInit, ControlValueAccessor
259259
}
260260
}
261261

262-
@HostListener("document:click", ["$event"])
263-
public onClickOutsideHandler(event) {
264-
if (
265-
event.target.offsetParent &&
266-
event.target.offsetParent?.getAttribute("class")
267-
) {
268-
if (
269-
!event.target.offsetParent
270-
.getAttribute("class")
271-
.includes("mde-popover-panel") &&
272-
!event.target.offsetParent
273-
.getAttribute("class")
274-
.includes("mat-calendar-period") &&
275-
!event.target.offsetParent
276-
.getAttribute("class")
277-
.includes("mat-calendar-table") &&
278-
!event.target.getAttribute("class")
279-
.includes("mat-calendar-previous-button") &&
280-
!event.target.getAttribute("class")
281-
.includes("mat-calendar-next-button") &&
282-
!event.target.getAttribute("class")
283-
.includes("mat-calendar")
284-
285-
) {
286-
this.checkOpenCalendar();
287-
}
288-
} else {
289-
this.checkOpenCalendar();
290-
}
262+
@HostListener("document:click", ["$event"])
263+
public onClickOutsideHandler(event)
264+
{
265+
if (this._isCalendarOpened && !this.calender.nativeElement.contains(event.target) && !this.calendarButton.nativeElement.contains(event.target))
266+
{
267+
this._isOpenClicked = false;
268+
this._isSelectingDate = false;
269+
this.checkOpenCalendar();
270+
}
291271
}
292272

293273
private checkOpenCalendar() {
@@ -443,7 +423,7 @@ export class DxcDateComponent implements OnChanges, OnInit, ControlValueAccessor
443423
}
444424
`;
445425
}
446-
426+
447427
getDynamicStyle() {
448428
return css`
449429
&.disabled {

0 commit comments

Comments
 (0)