Fix autocomplete on enter

master
Max Ehrlicher-Schmidt 4 years ago
parent 100f53100d
commit a21920560f

@ -12,7 +12,7 @@
<mat-option <mat-option
*ngFor="let object of filteredPossibleObjects" *ngFor="let object of filteredPossibleObjects"
[value]="nameToShowInSelection(object)" [value]="nameToShowInSelection(object)"
(click)="onOptionClicked($event, object, trigger)" (onSelectionChange)="onOptionSelected(object, trigger)"
> >
{{ nameToShowInSelection(object) }} {{ nameToShowInSelection(object) }}
</mat-option> </mat-option>

@ -68,13 +68,14 @@ export class AutocompleteSelectComponent implements OnInit {
.valueChanges.subscribe(() => this.filterPossibleObjects()); .valueChanges.subscribe(() => this.filterPossibleObjects());
} }
onOptionClicked(event: Event, element: any, trigger: MatAutocompleteTrigger) { onOptionSelected(element: any, trigger: MatAutocompleteTrigger) {
event.stopPropagation();
if (this.keepAutocompleteOpenAfterClick) { if (this.keepAutocompleteOpenAfterClick) {
trigger.openPanel(); trigger.openPanel();
} }
this.addForm.get('addGroup').reset(); this.addForm.get('addGroup').setValue('');
this.selectedElementChange.emit(element); this.selectedElementChange.emit(element);
this.filterPossibleObjects();
} }
filterPossibleObjects() { filterPossibleObjects() {

Loading…
Cancel
Save