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,7 +37,6 @@ | ||
37 | [matAutocomplete]="labelAutocomplete" | 37 | [matAutocomplete]="labelAutocomplete" |
38 | [matChipInputFor]="chipList" | 38 | [matChipInputFor]="chipList" |
39 | [matChipInputSeparatorKeyCodes]="separatorKeysCodes" | 39 | [matChipInputSeparatorKeyCodes]="separatorKeysCodes" |
40 | - matChipInputAddOnBlur | ||
41 | (matChipInputTokenEnd)="add($event)"> | 40 | (matChipInputTokenEnd)="add($event)"> |
42 | </mat-chip-list> | 41 | </mat-chip-list> |
43 | <mat-autocomplete #labelAutocomplete="matAutocomplete" | 42 | <mat-autocomplete #labelAutocomplete="matAutocomplete" |
@@ -36,7 +36,6 @@ | @@ -36,7 +36,6 @@ | ||
36 | [matAutocomplete]="entitySubtypeAutocomplete" | 36 | [matAutocomplete]="entitySubtypeAutocomplete" |
37 | [matChipInputFor]="chipList" | 37 | [matChipInputFor]="chipList" |
38 | [matChipInputSeparatorKeyCodes]="separatorKeysCodes" | 38 | [matChipInputSeparatorKeyCodes]="separatorKeysCodes" |
39 | - matChipInputAddOnBlur | ||
40 | (matChipInputTokenEnd)="chipAdd($event)"> | 39 | (matChipInputTokenEnd)="chipAdd($event)"> |
41 | </mat-chip-list> | 40 | </mat-chip-list> |
42 | <mat-autocomplete #entitySubtypeAutocomplete="matAutocomplete" | 41 | <mat-autocomplete #entitySubtypeAutocomplete="matAutocomplete" |
@@ -203,7 +203,7 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, | @@ -203,7 +203,7 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, | ||
203 | this.dirty = true; | 203 | this.dirty = true; |
204 | } | 204 | } |
205 | 205 | ||
206 | - add(entitySubtype: string): void { | 206 | + private add(entitySubtype: string): void { |
207 | if (!this.modelValue || this.modelValue.indexOf(entitySubtype) === -1) { | 207 | if (!this.modelValue || this.modelValue.indexOf(entitySubtype) === -1) { |
208 | if (!this.modelValue) { | 208 | if (!this.modelValue) { |
209 | this.modelValue = []; | 209 | this.modelValue = []; |
@@ -213,13 +213,12 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, | @@ -213,13 +213,12 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, | ||
213 | this.entitySubtypeListFormGroup.get('entitySubtypeList').setValue(this.entitySubtypeList); | 213 | this.entitySubtypeListFormGroup.get('entitySubtypeList').setValue(this.entitySubtypeList); |
214 | } | 214 | } |
215 | this.propagateChange(this.modelValue); | 215 | this.propagateChange(this.modelValue); |
216 | - this.clear(); | ||
217 | } | 216 | } |
218 | 217 | ||
219 | chipAdd(event: MatChipInputEvent): void { | 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 | this.clear(''); | 223 | this.clear(''); |
225 | } | 224 | } |
@@ -234,7 +233,6 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, | @@ -234,7 +233,6 @@ export class EntitySubTypeListComponent implements ControlValueAccessor, OnInit, | ||
234 | this.modelValue = null; | 233 | this.modelValue = null; |
235 | } | 234 | } |
236 | this.propagateChange(this.modelValue); | 235 | this.propagateChange(this.modelValue); |
237 | - this.clear(); | ||
238 | } | 236 | } |
239 | } | 237 | } |
240 | 238 |