Fix non-multipl os-search-val-selector
Fixes a bug there non multiple uses of search value selector was submitting the value twice due to late alterations of internal form objects
This commit is contained in:
parent
7b0f8e3c25
commit
a188abed48
@ -6,7 +6,7 @@
|
||||
(openedChange)="openSelect($event)"
|
||||
>
|
||||
<!-- Custom display of selected items -->
|
||||
<mat-select-trigger>
|
||||
<mat-select-trigger *ngIf="multiple">
|
||||
<ng-container *ngIf="selectedItems?.length">
|
||||
<span *ngFor="let item of selectedItems; let i = index">
|
||||
{{ item.getTitle() | translate }}<span *ngIf="i < selectedItems.length - 1">, </span>
|
||||
|
@ -124,9 +124,12 @@ export class SearchValueSelectorComponent extends BaseFormControlComponentDirect
|
||||
}
|
||||
|
||||
public get selectedItems(): Selectable[] {
|
||||
return this.selectableItems && this.contentForm.value
|
||||
? this.selectableItems.filter(item => this.contentForm.value.includes(item.id))
|
||||
: [];
|
||||
if (this.multiple && this.selectableItems?.length && this.contentForm.value) {
|
||||
return this.selectableItems.filter(item => {
|
||||
return this.contentForm.value.includes(item.id);
|
||||
});
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public controlType = 'search-value-selector';
|
||||
@ -197,7 +200,7 @@ export class SearchValueSelectorComponent extends BaseFormControlComponentDirect
|
||||
}
|
||||
|
||||
public onSelectionChange(change: MatOptionSelectionChange): void {
|
||||
if (change.isUserInput) {
|
||||
if (this.multiple && change.isUserInput) {
|
||||
const value = change.source.value;
|
||||
this.addRemoveId(value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user