Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(combo): update touched property and apply invalid color on blur when required - follow-up - 17.2.x #14968

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading