Skip to content

Commit

Permalink
Fix the BaseFromSelect component (#614)
Browse files Browse the repository at this point in the history
Previously it only accepted a list of strings. It now also will accept a
list of SelectOption objects, which must include label and value keys.
  • Loading branch information
thinkst-marco authored Nov 20, 2024
1 parent 8946138 commit 333e672
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions frontend_vue/src/components/base/BaseFormSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
:id="id"
class="v-select"
:options="options"
:value="value"
:label="label"
:searchable="false"
:placeholder="placeholder"
@input="handleSelectOption"
Expand All @@ -36,10 +34,12 @@
import { toRef, onMounted } from 'vue';
import { useField } from 'vee-validate';
export type SelectOption = { label: string, value: string };
const props = defineProps<{
id: string;
label: string;
options: string[];
options: string[] | SelectOption[];
placeholder?: string;
}>();
Expand All @@ -61,7 +61,10 @@ onMounted(() => {
}
});
function handleSelectOption(value: string) {
function handleSelectOption(value: string | SelectOption) {
if (typeof value === 'object') {
value = value.value
};
handleChange(value);
emits('selectOption', value);
}
Expand Down

0 comments on commit 333e672

Please sign in to comment.