Skip to content

Commit 5a9e9fb

Browse files
fix(IgxTimePicker): set displayValue to mask if no value is present #6494
1 parent 32a158c commit 5a9e9fb

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

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

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { InteractionMode } from '../core/enums';
1212
import { IgxIconModule } from '../icon';
1313
import { IgxToggleModule } from '../directives/toggle/toggle.directive';
1414

15-
describe('IgxTimePicker', () => {
15+
fdescribe('IgxTimePicker', () => {
1616
configureTestSuite();
1717
beforeEach(async(() => {
1818
TestBed.configureTestingModule({
@@ -201,8 +201,8 @@ describe('IgxTimePicker', () => {
201201
it('Should not throw Validation Failed event with null value passed in', fakeAsync(() => {
202202
const fixture = TestBed.createComponent(IgxTimePickerWithPmTimeComponent);
203203
fixture.componentInstance.dateValue = null;
204+
fixture.componentInstance.mode = 'dropdown';
204205
fixture.detectChanges();
205-
206206
const timePicker = fixture.componentInstance.timePicker;
207207
const dom = fixture.debugElement;
208208
const timePickerTarget = dom.query(By.directive(IgxInputDirective));
@@ -218,12 +218,12 @@ describe('IgxTimePicker', () => {
218218
fixture.detectChanges();
219219

220220
expect(timePicker.onValidationFailed.emit).not.toHaveBeenCalled();
221+
expect(timePicker.displayValue).toEqual('--:-- --');
221222
}));
222223

223224
it('TimePicker cancel button', fakeAsync(() => {
224225
const fixture = TestBed.createComponent(IgxTimePickerWithPmTimeComponent);
225226
fixture.detectChanges();
226-
227227
const timePicker = fixture.componentInstance.timePicker;
228228
const dom = fixture.debugElement;
229229
const initialTime = dom.query(By.directive(IgxInputDirective)).nativeElement.value;
@@ -1976,12 +1976,13 @@ export class IgxTimePickerWithPassedTimeComponent {
19761976

19771977
@Component({
19781978
template: `
1979-
<igx-time-picker [value]="dateValue" [format]="customFormat"></igx-time-picker>
1979+
<igx-time-picker [mode]="mode" [value]="dateValue" [format]="customFormat"></igx-time-picker>
19801980
`
19811981
})
19821982
export class IgxTimePickerWithPmTimeComponent {
1983-
public dateValue: Date = new Date(2017, 7, 7, 12, 27);
1984-
public customFormat = 'h:mm tt';
1983+
public dateValue: Date = new Date(2017, 7, 7, 12, 27, 23);
1984+
public customFormat = 'h:mm:ss tt';
1985+
public mode = 'dialog';
19851986
@ViewChild(IgxTimePickerComponent, { static: true }) public timePicker: IgxTimePickerComponent;
19861987
}
19871988

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ export class IgxTimePickerComponent implements
12941294
const oldValue = this.value;
12951295
const newVal = this._convertMinMaxValue(this.displayValue);
12961296

1297-
if (!this.displayValue && this.displayValue === this._formatTime(this.value, this.format)) {
1297+
if (this.displayValue === this.parseMask(false)) {
12981298
return;
12991299
}
13001300

@@ -1566,8 +1566,8 @@ export class IgxTimePickerComponent implements
15661566
* ```
15671567
*/
15681568
public cancelButtonClick(): void {
1569-
if (this.mode === InteractionMode.DropDown && this.value) {
1570-
this.displayValue = this._formatTime(this.value, this.format);
1569+
if (this.mode === InteractionMode.DropDown) {
1570+
this.displayValue = this.value ? this._formatTime(this.value, this.format) : this.parseMask(false);
15711571
}
15721572

15731573
this.close();

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<article class="timepicker-column">
77
<h4 class="sample-title">Time Picker with Dropdown</h4>
88
<div class="sample-description">{{showDate(date)}}</div>
9-
<div class="preview" style="width: 200px">
10-
<igx-time-picker #tp (onValueChanged)="valueChanged($event)"
9+
<div class="preview" style="width: 280px">
10+
<igx-time-picker #tp (onValueChanged)="valueChanged($event)" [minValue]="'9:15 AM'" [maxValue]="'9: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)