Skip to content

Commit b262f11

Browse files
fix(IgxTimePicker): set displayValue to mask if no value is present #6494
1 parent a656f31 commit b262f11

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

projects/igniteui-angular/src/lib/time-picker/time-picker.component.spec.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ describe('IgxTimePicker', () => {
186186
it('Should not throw Validation Failed event with null value passed in', fakeAsync(() => {
187187
const fixture = TestBed.createComponent(IgxTimePickerWithPmTimeComponent);
188188
fixture.componentInstance.dateValue = null;
189+
fixture.componentInstance.mode = 'dropdown';
189190
fixture.detectChanges();
190-
191191
const timePicker = fixture.componentInstance.timePicker;
192192
const dom = fixture.debugElement;
193193
const timePickerTarget = dom.query(By.directive(IgxInputDirective));
@@ -203,12 +203,12 @@ describe('IgxTimePicker', () => {
203203
fixture.detectChanges();
204204

205205
expect(timePicker.onValidationFailed.emit).not.toHaveBeenCalled();
206+
expect(timePicker.displayValue).toEqual('--:--:-- --');
206207
}));
207208

208209
it('TimePicker cancel button', fakeAsync(() => {
209210
const fixture = TestBed.createComponent(IgxTimePickerWithPmTimeComponent);
210211
fixture.detectChanges();
211-
212212
const timePicker = fixture.componentInstance.timePicker;
213213
const dom = fixture.debugElement;
214214
const initialTime = dom.query(By.directive(IgxInputDirective)).nativeElement.value;
@@ -2046,12 +2046,13 @@ export class IgxTimePickerWithPassedTimeComponent {
20462046

20472047
@Component({
20482048
template: `
2049-
<igx-time-picker [value]="dateValue" [format]="customFormat"></igx-time-picker>
2049+
<igx-time-picker [mode]="mode" [value]="dateValue" [format]="customFormat"></igx-time-picker>
20502050
`
20512051
})
20522052
export class IgxTimePickerWithPmTimeComponent {
20532053
public dateValue: Date = new Date(2017, 7, 7, 12, 27, 23);
20542054
public customFormat = 'h:mm:ss tt';
2055+
public mode = 'dialog';
20552056
@ViewChild(IgxTimePickerComponent, { static: true }) public timePicker: IgxTimePickerComponent;
20562057
}
20572058

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ export class IgxTimePickerComponent implements
14771477
const oldValue = this.value;
14781478
const newVal = this._convertMinMaxValue(this.displayValue);
14791479

1480-
if (!this.displayValue && this.displayValue === this._formatTime(this.value, this.format)) {
1480+
if (this.displayValue === this.parseMask(false)) {
14811481
return;
14821482
}
14831483

@@ -1795,8 +1795,8 @@ export class IgxTimePickerComponent implements
17951795
* ```
17961796
*/
17971797
public cancelButtonClick(): void {
1798-
if (this.mode === InteractionMode.DropDown && this.value) {
1799-
this.displayValue = this._formatTime(this.value, this.format);
1798+
if (this.mode === InteractionMode.DropDown) {
1799+
this.displayValue = this.value ? this._formatTime(this.value, this.format) : this.parseMask(false);
18001800
}
18011801

18021802
this.close();

src/app/time-picker/time-picker.sample.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<h4 class="sample-title">Time Picker with Dropdown</h4>
88
<div class="sample-description">{{showDate(date)}}</div>
99
<div class="preview" style="width: 280px">
10-
<igx-time-picker #tp (onValueChanged)="valueChanged($event)"
10+
<igx-time-picker #tp (onValueChanged)="valueChanged($event)" [minValue]="'9:15 AM'" [maxValue]="'10:15 PM'"
1111
(onValidationFailed)="validationFailed($event)" [mode]="mode" [isSpinLoop]="isSpinLoop"
1212
[(ngModel)]="date" [itemsDelta]="itemsDelta" [format]="format">
1313
</igx-time-picker>

0 commit comments

Comments
 (0)