Skip to content

Commit aeed8fe

Browse files
Merge pull request #14963 from IgniteUI/aahmedov/fix-touched-invalid-color-follow-up-master
fix(combo): update touched property and apply invalid color on blur when required - follow-up - master
2 parents 5d3c371 + 2aaeea8 commit aeed8fe

File tree

3 files changed

+7
-13
lines changed

3 files changed

+7
-13
lines changed

projects/igniteui-angular/src/lib/combo/combo.common.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,15 +1202,15 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
12021202
this.searchValue = '';
12031203
if (!e.event) {
12041204
this.comboInput?.nativeElement.focus();
1205+
} else {
1206+
this._onTouchedCallback();
1207+
this.updateValidity();
12051208
}
12061209
}
12071210

12081211
/** @hidden @internal */
12091212
public handleClosed() {
12101213
this.closed.emit({ owner: this });
1211-
if(this.comboInput.nativeElement !== this.document.activeElement){
1212-
this.validateComboState();
1213-
}
12141214
}
12151215

12161216
/** @hidden @internal */
@@ -1250,15 +1250,10 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
12501250
public onBlur() {
12511251
if (this.collapsed) {
12521252
this._onTouchedCallback();
1253-
this.validateComboState();
1253+
this.updateValidity();
12541254
}
12551255
}
12561256

1257-
/** @hidden @internal */
1258-
public onFocus(): void {
1259-
this._onTouchedCallback();
1260-
}
1261-
12621257
/** @hidden @internal */
12631258
public setActiveDescendant(): void {
12641259
this.activeDescendant = this.dropdown.focusedItem?.id || '';
@@ -1283,7 +1278,7 @@ export abstract class IgxComboBaseDirective implements IgxComboBase, AfterViewCh
12831278
this.manageRequiredAsterisk();
12841279
};
12851280

1286-
private validateComboState() {
1281+
private updateValidity() {
12871282
if (this.ngControl && this.ngControl.invalid) {
12881283
this.valid = IgxInputState.INVALID;
12891284
} else {

projects/igniteui-angular/src/lib/combo/combo.component.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
role="combobox" aria-haspopup="listbox"
1414
[attr.aria-expanded]="!dropdown.collapsed" [attr.aria-controls]="dropdown.listId"
1515
[attr.aria-labelledby]="ariaLabelledBy || label?.id || placeholder"
16-
(blur)="onBlur()"
17-
(focus)="onFocus()" />
16+
(blur)="onBlur()" />
1817
<ng-container ngProjectAs="igx-suffix">
1918
<ng-content select="igx-suffix"></ng-content>
2019
</ng-container>

projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3615,7 +3615,7 @@ describe('igxCombo', () => {
36153615
combo.open();
36163616
input.triggerEventHandler('focus', {});
36173617
fixture.detectChanges();
3618-
expect(ngModel.touched).toBeTrue();
3618+
expect(ngModel.touched).toBeFalse();
36193619
combo.searchInput.nativeElement.focus();
36203620
fixture.detectChanges();
36213621
const documentClickEvent = new MouseEvent('click', { bubbles: true });

0 commit comments

Comments
 (0)