autocomplete fix
This commit is contained in:
parent
da2c6f7ee5
commit
54779bf53f
|
@ -1,15 +1,13 @@
|
||||||
<div class="row auto-complete">
|
<div class="row auto-complete">
|
||||||
<mat-chip-list #chipList [disabled]="disabled">
|
<mat-chip-list #chipList [disabled]="disabled" class="chip-list">
|
||||||
<mat-chip *ngIf="value" [removable]="true" (removed)="chipRemove()">
|
<mat-chip *ngIf="value" [removable]="true" (removed)="chipRemove()">
|
||||||
{{_displayFn(value)}}
|
{{_displayFn(value)}}
|
||||||
<mat-icon matChipRemove *ngIf="!disabled">cancel</mat-icon>
|
<mat-icon matChipRemove *ngIf="!disabled">cancel</mat-icon>
|
||||||
</mat-chip>
|
</mat-chip>
|
||||||
<input matInput class="col" autocomplete="off" [placeholder]="placeholder" [matAutocomplete]="auto" [ngModel]="_inputValue" (ngModelChange)="_inputValueChange($event)" [disabled]="disabled || (value !== null)" (focus)="_onInputFocus()" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="true">
|
<input matInput class="col" autocomplete="off" [placeholder]="placeholder" [matAutocomplete]="auto" [ngModel]="_inputValue" (ngModelChange)="_inputValueChange($event)" [disabled]="disabled || (value != null && value !== '')" (focus)="_onInputFocus()" [matChipInputFor]="chipList" [matChipInputSeparatorKeyCodes]="separatorKeysCodes" [matChipInputAddOnBlur]="true">
|
||||||
|
|
||||||
|
|
||||||
</mat-chip-list>
|
</mat-chip-list>
|
||||||
|
|
||||||
<mat-progress-spinner mode="indeterminate" [class.not-loading]="!loading" [diameter]="17"></mat-progress-spinner>
|
<mat-progress-spinner class="progress-loader" mode="indeterminate" [class.not-loading]="!loading" [diameter]="17"></mat-progress-spinner>
|
||||||
<mat-autocomplete #auto="matAutocomplete" [displayWith]="_displayFn.bind(this)" (optionSelected)="_optionSelected($event)">
|
<mat-autocomplete #auto="matAutocomplete" [displayWith]="_displayFn.bind(this)" (optionSelected)="_optionSelected($event)">
|
||||||
<span *ngIf="_groupedItems">
|
<span *ngIf="_groupedItems">
|
||||||
<mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title">
|
<mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title">
|
||||||
|
|
|
@ -5,6 +5,15 @@
|
||||||
.not-loading {
|
.not-loading {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chip-list {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-loader {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.two-line-mat-option {
|
.two-line-mat-option {
|
||||||
|
|
|
@ -75,7 +75,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
|
||||||
}
|
}
|
||||||
set value(value: any | null) {
|
set value(value: any | null) {
|
||||||
this._selectedValue = value;
|
this._selectedValue = value;
|
||||||
this._inputValue = " ";
|
if (value && value != "") { this._inputValue = " "; }
|
||||||
this.stateChanges.next();
|
this.stateChanges.next();
|
||||||
}
|
}
|
||||||
private _selectedValue;
|
private _selectedValue;
|
||||||
|
@ -149,7 +149,7 @@ export class SingleAutoCompleteComponent implements OnInit, MatFormFieldControl<
|
||||||
|
|
||||||
_optionSelected(event: MatAutocompleteSelectedEvent) {
|
_optionSelected(event: MatAutocompleteSelectedEvent) {
|
||||||
this._setValue(this.configuration.valueAssign ? this.configuration.valueAssign(event.option.value) : event.option.value);
|
this._setValue(this.configuration.valueAssign ? this.configuration.valueAssign(event.option.value) : event.option.value);
|
||||||
this._inputValue = " ";;
|
//this._inputValue = " ";
|
||||||
this.stateChanges.next();
|
this.stateChanges.next();
|
||||||
this.optionSelected.emit(event.option.value);
|
this.optionSelected.emit(event.option.value);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue