@@ -3416,6 +3416,28 @@ describe('igxCombo', () => {
34163416 expect ( combo . valid ) . toEqual ( IgxInputState . INITIAL ) ;
34173417 expect ( combo . comboInput . valid ) . toEqual ( IgxInputState . INITIAL ) ;
34183418 } ) ) ;
3419+
3420+ fit ( 'should mark the combo as touched and invalid when opened and the user clicks away' , fakeAsync ( ( ) => {
3421+ // Access the NgModel for the testCombo
3422+ const ngModel = fixture . debugElement . query ( By . directive ( NgModel ) ) . injector . get ( NgModel ) ;
3423+
3424+ // Initially, the combo should not be touched
3425+ expect ( combo . valid ) . toEqual ( IgxInputState . INITIAL ) ;
3426+ expect ( combo . comboInput . valid ) . toEqual ( IgxInputState . INITIAL ) ;
3427+ expect ( ngModel . touched ) . toBeFalse ( ) ;
3428+
3429+ combo . open ( ) ;
3430+ fixture . detectChanges ( ) ;
3431+
3432+ const documentClickEvent = new MouseEvent ( 'click' , { bubbles : true } ) ;
3433+ document . body . dispatchEvent ( documentClickEvent ) ;
3434+ fixture . detectChanges ( ) ;
3435+ tick ( ) ;
3436+
3437+ expect ( combo . valid ) . toEqual ( IgxInputState . INVALID ) ;
3438+ expect ( combo . comboInput . valid ) . toEqual ( IgxInputState . INVALID ) ;
3439+ expect ( ngModel . touched ) . toBeTrue ( ) ; // NgModel should now be marked as touched
3440+ } ) ) ;
34193441 } ) ;
34203442 } ) ;
34213443 describe ( 'Display density' , ( ) => {
@@ -3627,7 +3649,7 @@ class IgxComboFormComponent {
36273649@Component ( {
36283650 template : `
36293651 <form #form="ngForm">
3630- <igx-combo #testCombo class="input-container" [placeholder]="'Locations'"
3652+ <igx-combo #testCombo #testComboNgModel="ngModel" class="input-container" [placeholder]="'Locations'"
36313653 name="anyName" required [(ngModel)]="values"
36323654 [data]="items" [filterable]="filterableFlag"
36333655 [displayKey]="'field'" [valueKey]="'field'"
0 commit comments