Skip to content

Commit

Permalink
Added fieldState to show existing values related to the field.
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorWebb96 committed Jun 11, 2024
1 parent 37d6af3 commit b7821e3
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@
// field type select
optionsTypeState = searchOptionsType === 'relationship' ? searchRelationship : searchOptionsType === 'searchFields' ? searchField : searchOptionsType === 'searchArray' ? searchArray : null;
$: debouncedSearch(searchString);
// Initialise selected values if fieldState?.value is present
$: if (fieldState?.value) {
if (type === 'string') {
selectedLabels = [{ label: fieldState.value }];
selectedValues = [{ value: fieldState.value }];
} else {
selectedLabels = fieldState.value.map(item => ({ label: item[labelColumn] }));
selectedValues = fieldState.value.map(item => ({ value: item[valueColumn] }));
}
}
const search = async (searchString) => {
if (searchString == null || searchString.length < 1) {
return
Expand Down

0 comments on commit b7821e3

Please sign in to comment.