Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: AutompleteSelect when options is already filled and analytics StackedBarsNormalized with selected implementation groups #1493

Merged
merged 3 commits into from
Feb 11, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions frontend/src/lib/components/Forms/AutocompleteSelect.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
let selected: (typeof options)[] = [];
let selectedValues: (string | undefined)[] = [];
let isInternalUpdate = false;
let optionsLoaded = false;
let optionsLoaded = options.length ? true: false;
let initialValue = $value; // Store initial value
const default_value = nullable ? null : selectedValues[0];

Expand Down Expand Up @@ -141,21 +141,19 @@
if (updateMissingConstraint) {
updateMissingConstraint(field, isMissing);
}

// After options are loaded, set initial selection using stored initial value
if (initialValue) {
selected = options.filter((item) =>
Array.isArray(initialValue)
? initialValue.includes(item.value)
: item.value === initialValue
);
} else if (options.length === 1 && $constraints?.required) {
selected = [options[0]];
}

optionsLoaded = true;
}
}
// After options are loaded, set initial selection using stored initial value
if (initialValue) {
selected = options.filter((item) =>
Array.isArray(initialValue)
? initialValue.includes(item.value)
: item.value === initialValue
);
} else if (options.length === 1 && $constraints?.required) {
selected = [options[0]];
}
} catch (error) {
console.error(`Error fetching ${optionsEndpoint}:`, error);
} finally {
Expand Down
Loading