Skip to content

Commit 3eab25e

Browse files
refactor(IgxTimePicker): suppressInputAutofocus on default dropdown template
1 parent a24c2c0 commit 3eab25e

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ng-template #dropdownInputTemplate>
2-
<igx-input-group #group (mousedown)="mouseDown($event)">
2+
<igx-input-group #group (mousedown)="mouseDown($event)" [suppressInputAutofocus]="true">
33
<label igxLabel>Time</label>
44
<igx-prefix (click)="openDialog(group.element.nativeElement)">
55
<igx-icon>access_time</igx-icon>

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,17 +1846,14 @@ describe('IgxTimePicker', () => {
18461846
fixture.componentInstance.format = 'hh tt';
18471847
fixture.componentInstance.customDate = new Date(2018, 10, 27, 17, 45, 0, 0);
18481848
fixture.detectChanges();
1849-
18501849
const clearTime = dom.queryAll(By.css('.igx-icon'))[1];
18511850

18521851
UIInteractions.simulateClickAndSelectEvent(clearTime);
18531852
fixture.detectChanges();
18541853
input.nativeElement.dispatchEvent(new Event('focus'));
1855-
tick();
18561854
fixture.detectChanges();
18571855

18581856
input.nativeElement.dispatchEvent(new Event('blur'));
1859-
tick();
18601857
fixture.detectChanges();
18611858

18621859
expect(input.nativeElement.value).toEqual('');

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

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,13 +1944,12 @@ export class IgxTimePickerComponent implements
19441944
this.isNotEmpty = false;
19451945

19461946
const oldVal = new Date(this.value);
1947-
19481947
this.displayValue = this.parseMask(false);
19491948
requestAnimationFrame(() => {
19501949
this._setCursorPosition(0);
19511950
});
1952-
// TODO: refactoring - this.value should be null #8135
1953-
this.value.setHours(0, 0);
1951+
// TODO: refactoring - this.value should be null #6585
1952+
this.value?.setHours(0, 0, 0);
19541953

19551954
if (oldVal.getTime() !== this.value.getTime()) {
19561955
const args: IgxTimePickerValueChangedEventArgs = {
@@ -1968,7 +1967,7 @@ export class IgxTimePickerComponent implements
19681967
* @hidden
19691968
*/
19701969
public onInput(event): void {
1971-
const inputMask = event.target.value;
1970+
const inputMask: string = event.target.value;
19721971
const oldVal = new Date(this.value);
19731972

19741973
this.isNotEmpty = inputMask !== this.parseMask(false);
@@ -1984,20 +1983,19 @@ export class IgxTimePickerComponent implements
19841983
} else {
19851984
const args: IgxTimePickerValidationFailedEventArgs = {
19861985
timePicker: this,
1987-
currentValue: inputMask,
1986+
currentValue: new Date(inputMask),
19881987
setThroughUI: false
19891988
};
19901989
this.onValidationFailed.emit(args);
19911990
}
19921991
// handle cases where the user deletes the display value (when pressing backspace or delete)
1993-
} else if (inputMask === this.parseMask(false)) {
1992+
} else if (!this.value || inputMask.length === 0 || !this.isNotEmpty) {
19941993
this.isNotEmpty = false;
1995-
1996-
// TODO: refactoring - this.value should be null #8135
1997-
this.value.setHours(0, 0);
1994+
// TODO: refactoring - this.value should be null #6585
1995+
this.value?.setHours(0, 0, 0);
19981996
this.displayValue = inputMask;
1999-
2000-
if (oldVal.getTime() !== this.value.getTime()) {
1997+
if (oldVal.getTime() !== this.value?.getTime()) {
1998+
// TODO: Do not emit event when the editor is empty #6482
20011999
const args: IgxTimePickerValueChangedEventArgs = {
20022000
oldValue: oldVal,
20032001
newValue: this.value
@@ -2024,7 +2022,7 @@ export class IgxTimePickerComponent implements
20242022
this.isNotEmpty = value !== '';
20252023
this.displayValue = value;
20262024

2027-
if (value && value !== this.parseMask()) {
2025+
if (value && (value !== this.parseMask() || value !== this.parseMask(false))) {
20282026
if (this._isEntryValid(value)) {
20292027
const newVal = this.convertMinMaxValue(value);
20302028
if (!this.value || this.value.getTime() !== newVal.getTime()) {

0 commit comments

Comments
 (0)