@@ -48,7 +48,8 @@ describe('MdAutocomplete', () => {
4848 AutocompleteWithoutForms ,
4949 NgIfAutocomplete ,
5050 AutocompleteWithNgModel ,
51- AutocompleteWithOnPushDelay
51+ AutocompleteWithOnPushDelay ,
52+ AutocompleteWithNativeInput
5253 ] ,
5354 providers : [
5455 { provide : OverlayContainer , useFactory : ( ) => {
@@ -1065,6 +1066,24 @@ describe('MdAutocomplete', () => {
10651066 } ) ) ;
10661067 } ) ;
10671068
1069+ describe ( 'without mdInput' , ( ) => {
1070+ let fixture : ComponentFixture < AutocompleteWithNativeInput > ;
1071+
1072+ beforeEach ( ( ) => {
1073+ fixture = TestBed . createComponent ( AutocompleteWithNativeInput ) ;
1074+ fixture . detectChanges ( ) ;
1075+ } ) ;
1076+
1077+ it ( 'should not throw when clicking outside' , async ( ( ) => {
1078+ dispatchFakeEvent ( fixture . debugElement . query ( By . css ( 'input' ) ) . nativeElement , 'focus' ) ;
1079+ fixture . detectChanges ( ) ;
1080+
1081+ fixture . whenStable ( ) . then ( ( ) => {
1082+ expect ( ( ) => dispatchFakeEvent ( document , 'click' ) ) . not . toThrow ( ) ;
1083+ } ) ;
1084+ } ) ) ;
1085+ } ) ;
1086+
10681087 describe ( 'misc' , ( ) => {
10691088
10701089 it ( 'should allow basic use without any forms directives' , ( ) => {
@@ -1373,6 +1392,33 @@ class AutocompleteWithOnPushDelay implements OnInit {
13731392 }
13741393}
13751394
1395+ @Component ( {
1396+ template : `
1397+ <input placeholder="Choose" [mdAutocomplete]="auto" [formControl]="optionCtrl">
1398+
1399+ <md-autocomplete #auto="mdAutocomplete">
1400+ <md-option *ngFor="let option of filteredOptions | async" [value]="option">
1401+ {{option}}
1402+ </md-option>
1403+ </md-autocomplete>
1404+ `
1405+ } )
1406+ class AutocompleteWithNativeInput {
1407+ optionCtrl = new FormControl ( ) ;
1408+ filteredOptions : Observable < any > ;
1409+ options = [ 'En' , 'To' , 'Tre' , 'Fire' , 'Fem' ] ;
1410+
1411+ @ViewChild ( MdAutocompleteTrigger ) trigger : MdAutocompleteTrigger ;
1412+ @ViewChildren ( MdOption ) mdOptions : QueryList < MdOption > ;
1413+
1414+ constructor ( ) {
1415+ this . filteredOptions = this . optionCtrl . valueChanges . startWith ( null ) . map ( ( val ) => {
1416+ return val ? this . options . filter ( option => new RegExp ( val , 'gi' ) . test ( option ) )
1417+ : this . options . slice ( ) ;
1418+ } ) ;
1419+ }
1420+ }
1421+
13761422
13771423/** This is a mock keyboard event to test keyboard events in the autocomplete. */
13781424class MockKeyboardEvent {
0 commit comments