@@ -76,6 +76,7 @@ import { startWith } from 'rxjs/operators/startWith';
7676 [id]="id"
7777 [formControl]="form"
7878 [matAutocomplete]="auto"
79+ (keyup)="updateFilter($event)"
7980 />
8081 <mat-autocomplete
8182 autoActiveFirstOption
@@ -96,6 +97,7 @@ import { startWith } from 'rxjs/operators/startWith';
9697export class AutocompleteControlRenderer extends JsonFormsControl {
9798 @Input ( ) options : string [ ] ;
9899 filteredOptions : Observable < string [ ] > ;
100+ shouldNotFilter : boolean ;
99101
100102 constructor ( ngRedux : NgRedux < JsonFormsState > ) {
101103 super ( ngRedux ) ;
@@ -104,21 +106,34 @@ export class AutocompleteControlRenderer extends JsonFormsControl {
104106
105107 ngOnInit ( ) {
106108 super . ngOnInit ( ) ;
109+ this . shouldNotFilter = true ;
107110 this . filteredOptions = this . form . valueChanges . pipe (
108111 startWith ( '' ) ,
109112 map ( val => this . filter ( val ) )
110113 ) ;
111114 }
112115
116+ updateFilter ( event : any ) {
117+ // ENTER
118+ if ( event . keyCode === 13 ) {
119+ this . shouldNotFilter = true ;
120+ } else {
121+ this . shouldNotFilter = false ;
122+ }
123+ }
124+
113125 onSelect ( ev : MatAutocompleteSelectedEvent ) {
114126 const path = composeWithUi ( this . uischema as ControlElement , this . path ) ;
127+ this . shouldNotFilter = true ;
115128 this . ngRedux . dispatch ( Actions . update ( path , ( ) => ev . option . value ) ) ;
116129 this . triggerValidation ( ) ;
117130 }
118131
119132 filter ( val : string ) : string [ ] {
120133 return ( this . options || this . scopedSchema . enum || [ ] ) . filter (
121- option => ! val || option . toLowerCase ( ) . indexOf ( val . toLowerCase ( ) ) === 0
134+ option =>
135+ this . shouldNotFilter ||
136+ ( ! val || option . toLowerCase ( ) . indexOf ( val . toLowerCase ( ) ) === 0 )
122137 ) ;
123138 }
124139 protected getOwnProps ( ) : OwnPropsOfAutoComplete {
0 commit comments