Skip to content

Commit c579a16

Browse files
committed
chore(date-picker): fix check in clear method #7577
1 parent 3e11d6b commit c579a16

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

projects/igniteui-angular/src/lib/date-picker/date-picker.component.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import { IgxInputGroupModule, IgxInputDirective, IgxInputGroupComponent, IgxInpu
3434
import { Subject, fromEvent, animationFrameScheduler, interval, Subscription } from 'rxjs';
3535
import { filter, takeUntil, throttle } from 'rxjs/operators';
3636
import { IgxOverlayOutletDirective } from '../directives/toggle/toggle.directive';
37-
import { IgxTextSelectionModule} from '../directives/text-selection/text-selection.directive';
37+
import { IgxTextSelectionModule } from '../directives/text-selection/text-selection.directive';
3838
import {
3939
OverlaySettings,
4040
IgxOverlayService,
@@ -145,7 +145,7 @@ const noop = () => { };
145145
`]
146146
})
147147
export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor,
148-
EditorProvider, OnInit, AfterViewInit, OnDestroy, AfterViewChecked {
148+
EditorProvider, OnInit, AfterViewInit, OnDestroy, AfterViewChecked {
149149
/**
150150
* Gets/Sets the `IgxDatePickerComponent` label.
151151
* @remarks
@@ -952,10 +952,10 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
952952
* @param date passed date that has to be set to the calendar.
953953
*/
954954
public selectDate(date: Date): void {
955-
const oldValue = this.value;
955+
const oldValue = this.value;
956956
this.value = date;
957957

958-
this.emitValueChangeEvent(oldValue, this.value );
958+
this.emitValueChangeEvent(oldValue, this.value);
959959
this.onSelection.emit(date);
960960
}
961961

@@ -967,9 +967,9 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
967967
* ```
968968
*/
969969
public deselectDate(): void {
970-
const oldValue = this.value;
970+
const oldValue = this.value;
971971
this.value = null;
972-
this.emitValueChangeEvent(oldValue, this.value );
972+
this.emitValueChangeEvent(oldValue, this.value);
973973
if (this.calendar) {
974974
this.calendar.deselectDate();
975975
}
@@ -984,7 +984,7 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
984984
* ```
985985
*/
986986
public openDialog(target?: HTMLElement): void {
987-
if (!this.collapsed) {
987+
if (!this.collapsed || this.disabled) {
988988
return;
989989
}
990990
switch (this.mode) {
@@ -1031,10 +1031,12 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
10311031
* @hidden @internal
10321032
*/
10331033
public clear(): void {
1034-
this.isEmpty = true;
1035-
this.invalidDate = '';
1036-
this.deselectDate();
1037-
this._setCursorPosition(0);
1034+
if (!this.disabled) {
1035+
this.isEmpty = true;
1036+
this.invalidDate = '';
1037+
this.deselectDate();
1038+
this._setCursorPosition(0);
1039+
}
10381040
}
10391041

10401042
/**
@@ -1052,10 +1054,10 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
10521054
date.setSeconds(this.value.getSeconds());
10531055
date.setMilliseconds(this.value.getMilliseconds());
10541056
}
1055-
const oldValue = this.value;
1057+
const oldValue = this.value;
10561058
this.value = date;
10571059

1058-
this.emitValueChangeEvent(oldValue, this.value );
1060+
this.emitValueChangeEvent(oldValue, this.value);
10591061
this.calendar.viewDate = date;
10601062
this.closeCalendar();
10611063
this.onSelection.emit(date);
@@ -1179,11 +1181,11 @@ export class IgxDatePickerComponent implements IDatePicker, ControlValueAccessor
11791181

11801182
if (this.disabledDates === null
11811183
|| (this.disabledDates !== null && !isDateInRanges(newValue, this.disabledDates))) {
1182-
const oldValue = this.value;
1183-
this.value = newValue;
1184+
const oldValue = this.value;
1185+
this.value = newValue;
11841186

1185-
this.emitValueChangeEvent(oldValue, this.value );
1186-
this.invalidDate = '';
1187+
this.emitValueChangeEvent(oldValue, this.value);
1188+
this.invalidDate = '';
11871189
} else {
11881190
const args: IDatePickerDisabledDateEventArgs = {
11891191
datePicker: this,

0 commit comments

Comments
 (0)