Skip to content

Commit

Permalink
Merge pull request #14968 from IgniteUI/aahmedov/fix-touched-invalid-…
Browse files Browse the repository at this point in the history
…color-follow-up-17.2.x

fix(combo): update touched property and apply invalid color on blur when required - follow-up - 17.2.x
  • Loading branch information
kacheshmarova authored Nov 5, 2024
2 parents 515bfda + 5557a76 commit 0457321
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
15 changes: 5 additions & 10 deletions projects/igniteui-angular/src/lib/combo/combo.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1206,15 +1206,15 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
this.searchValue = '';
if (!e.event) {
this.comboInput?.nativeElement.focus();
} else {
this._onTouchedCallback();
this.updateValidity();
}
}

/** @hidden @internal */
public handleClosed() {
this.closed.emit({ owner: this });
if(this.comboInput.nativeElement !== document.activeElement){
this.validateComboState();
}
}

/** @hidden @internal */
Expand Down Expand Up @@ -1254,15 +1254,10 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
public onBlur() {
if (this.collapsed) {
this._onTouchedCallback();
this.validateComboState();
this.updateValidity();
}
}

/** @hidden @internal */
public onFocus(): void {
this._onTouchedCallback();
}

/** @hidden @internal */
public setActiveDescendant(): void {
this.activeDescendant = this.dropdown.focusedItem?.id || '';
Expand All @@ -1287,7 +1282,7 @@ export abstract class IgxComboBaseDirective extends DisplayDensityBase implement
this.manageRequiredAsterisk();
};

private validateComboState() {
private updateValidity() {
if (this.ngControl && this.ngControl.invalid) {
this.valid = IgxInputState.INVALID;
} else {
Expand Down
3 changes: 1 addition & 2 deletions projects/igniteui-angular/src/lib/combo/combo.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
role="combobox" aria-haspopup="listbox"
[attr.aria-expanded]="!dropdown.collapsed" [attr.aria-controls]="dropdown.listId"
[attr.aria-labelledby]="ariaLabelledBy || label?.id || placeholder"
(blur)="onBlur()"
(focus)="onFocus()" />
(blur)="onBlur()" />
<ng-container ngProjectAs="igx-suffix">
<ng-content select="igx-suffix"></ng-content>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3425,7 +3425,8 @@ describe('igxCombo', () => {
combo.open();
input.triggerEventHandler('focus', {});
fixture.detectChanges();
expect(ngModel.touched).toBeTrue();
expect(ngModel.touched).toBeFalse();
fixture.detectChanges();
const documentClickEvent = new MouseEvent('click', { bubbles: true });
document.body.dispatchEvent(documentClickEvent);
fixture.detectChanges();
Expand Down

0 comments on commit 0457321

Please sign in to comment.