Skip to content

Commit 771f0f7

Browse files
committed
refactor(combo): Migrated to new validation behavior
1 parent c7d5554 commit 771f0f7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/components/combo/combo.spec.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { createFormAssociatedTestBed } from '../common/utils.spec.js';
66
import {
77
runValidationContainerTests,
88
type ValidationContainerTestsParams,
9+
ValidityHelpers,
910
} from '../common/validity-helpers.spec.js';
1011
import type IgcInputComponent from '../input/input.js';
1112
import IgcComboComponent from './combo.js';
@@ -593,27 +594,27 @@ describe('Combo', () => {
593594
await elementUpdated(combo);
594595

595596
expect(combo.checkValidity()).to.be.false;
596-
expect(combo.invalid).to.be.true;
597+
ValidityHelpers.isValid(combo).to.be.false;
597598

598599
combo.select();
599600
await elementUpdated(combo);
600601

601602
expect(combo.checkValidity()).to.be.true;
602-
expect(combo.invalid).to.be.false;
603+
ValidityHelpers.isValid(combo).to.be.true;
603604
});
604605

605606
it('reports validity when not required', async () => {
606607
combo.required = false;
607608
await elementUpdated(combo);
608609

609610
expect(combo.checkValidity()).to.be.true;
610-
expect(combo.invalid).to.be.false;
611+
ValidityHelpers.isValid(combo).to.be.true;
611612

612613
combo.deselect();
613614
await elementUpdated(combo);
614615

615616
expect(combo.checkValidity()).to.be.true;
616-
expect(combo.invalid).to.be.false;
617+
ValidityHelpers.isValid(combo).to.be.true;
617618
});
618619

619620
it('opens the list of options when Down or Alt+Down keys are pressed', async () => {

src/components/combo/combo.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ export default class IgcComboComponent<
622622
}
623623

624624
protected async handleMainInput({ detail }: CustomEvent<string>) {
625+
this._setTouchedState();
625626
this._show();
626627
this._state.searchTerm = detail;
627628

@@ -638,12 +639,12 @@ export default class IgcComboComponent<
638639
this.clearSingleSelection();
639640
}
640641

641-
private _handleBlur() {
642+
protected override _handleBlur() {
642643
if (this._selection.isEmpty) {
643644
this._displayValue = '';
644645
this.resetSearchTerm();
645646
}
646-
this.checkValidity();
647+
super._handleBlur();
647648
}
648649

649650
protected handleSearchInput({ detail }: CustomEvent<string>) {
@@ -836,6 +837,7 @@ export default class IgcComboComponent<
836837
}
837838

838839
protected handleMainInputKeydown(e: KeyboardEvent) {
840+
this._setTouchedState();
839841
this._navigation.navigateMainInput(e, this._list);
840842
}
841843

0 commit comments

Comments
 (0)