Commit 53a919e046272cfb0c494c6e7231bacaa3dcbce6
1 parent
f325edef
UI: Fix incorrect add chip for autocomplete component
Showing
3 changed files
with
4 additions
and
8 deletions
... | ... | @@ -37,7 +37,6 @@ |
37 | 37 | [matAutocomplete]="labelAutocomplete" |
38 | 38 | [matChipInputFor]="chipList" |
39 | 39 | [matChipInputSeparatorKeyCodes]="separatorKeysCodes" |
40 | - matChipInputAddOnBlur | |
41 | 40 | (matChipInputTokenEnd)="add($event)"> |
42 | 41 | </mat-chip-list> |
43 | 42 | <mat-autocomplete #labelAutocomplete="matAutocomplete" | ... | ... |
... | ... | @@ -36,7 +36,6 @@ |
36 | 36 | [matAutocomplete]="entitySubtypeAutocomplete" |
37 | 37 | [matChipInputFor]="chipList" |
38 | 38 | [matChipInputSeparatorKeyCodes]="separatorKeysCodes" |
39 | - matChipInputAddOnBlur | |
40 | 39 | (matChipInputTokenEnd)="chipAdd($event)"> |
41 | 40 | </mat-chip-list> |
42 | 41 | <mat-autocomplete #entitySubtypeAutocomplete="matAutocomplete" | ... | ... |
... | ... | @@ -203,7 +203,7 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, |
203 | 203 | this.dirty = true; |
204 | 204 | } |
205 | 205 | |
206 | - add(entitySubtype: string): void { | |
206 | + private add(entitySubtype: string): void { | |
207 | 207 | if (!this.modelValue || this.modelValue.indexOf(entitySubtype) === -1) { |
208 | 208 | if (!this.modelValue) { |
209 | 209 | this.modelValue = []; |
... | ... | @@ -213,13 +213,12 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, |
213 | 213 | this.entitySubtypeListFormGroup.get('entitySubtypeList').setValue(this.entitySubtypeList); |
214 | 214 | } |
215 | 215 | this.propagateChange(this.modelValue); |
216 | - this.clear(); | |
217 | 216 | } |
218 | 217 | |
219 | 218 | chipAdd(event: MatChipInputEvent): void { |
220 | - const value = event.value; | |
221 | - if ((value || '').trim()) { | |
222 | - this.add(value.trim()); | |
219 | + const value = (event.value || '').trim(); | |
220 | + if (value) { | |
221 | + this.add(value); | |
223 | 222 | } |
224 | 223 | this.clear(''); |
225 | 224 | } |
... | ... | @@ -234,7 +233,6 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, |
234 | 233 | this.modelValue = null; |
235 | 234 | } |
236 | 235 | this.propagateChange(this.modelValue); |
237 | - this.clear(); | |
238 | 236 | } |
239 | 237 | } |
240 | 238 | ... | ... |