Skip to content

Commit 0457321

Browse files
Merge pull request #14968 from IgniteUI/aahmedov/fix-touched-invalid-color-follow-up-17.2.x
fix(combo): update touched property and apply invalid color on blur when required - follow-up - 17.2.x
2 parents 515bfda + 5557a76 commit 0457321

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-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
@@ -1206,15 +1206,15 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
12061206
this.searchValue = '';
12071207
if (!e.event) {
12081208
this.comboInput?.nativeElement.focus();
1209+
} else {
1210+
this._onTouchedCallback();
1211+
this.updateValidity();
12091212
}
12101213
}
12111214

12121215
/** @hidden @internal */
12131216
public handleClosed() {
12141217
this.closed.emit({ owner: this });
1215-
if(this.comboInput.nativeElement !== document.activeElement){
1216-
this.validateComboState();
1217-
}
12181218
}
12191219

12201220
/** @hidden @internal */
@@ -1254,15 +1254,10 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
12541254
public onBlur() {
12551255
if (this.collapsed) {
12561256
this._onTouchedCallback();
1257-
this.validateComboState();
1257+
this.updateValidity();
12581258
}
12591259
}
12601260

1261-
/** @hidden @internal */
1262-
public onFocus(): void {
1263-
this._onTouchedCallback();
1264-
}
1265-
12661261
/** @hidden @internal */
12671262
public setActiveDescendant(): void {
12681263
this.activeDescendant = this.dropdown.focusedItem?.id || '';
@@ -1287,7 +1282,7 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
12871282
this.manageRequiredAsterisk();
12881283
};
12891284

1290-
private validateComboState() {
1285+
private updateValidity() {
12911286
if (this.ngControl && this.ngControl.invalid) {
12921287
this.valid = IgxInputState.INVALID;
12931288
} 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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3425,7 +3425,8 @@ describe('igxCombo', () => {
34253425
combo.open();
34263426
input.triggerEventHandler('focus', {});
34273427
fixture.detectChanges();
3428-
expect(ngModel.touched).toBeTrue();
3428+
expect(ngModel.touched).toBeFalse();
3429+
fixture.detectChanges();
34293430
const documentClickEvent = new MouseEvent('click', { bubbles: true });
34303431
document.body.dispatchEvent(documentClickEvent);
34313432
fixture.detectChanges();

0 commit comments

Comments
 (0)