Skip to content

Commit 5b58f6d

Browse files
authored
fix: improve selectedOptions computation for multi-select with isMulti (#94)
1 parent d63ebca commit 5b58f6d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Select.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,16 @@ const availableOptions = computed(() => {
146146
});
147147
148148
const selectedOptions = computed(() => {
149-
if (props.isMulti) {
150-
// We can safely assume it's an array due to the `isMulti` prop validation done earlier.
149+
if (props.isMulti && Array.isArray(selected.value)) {
151150
return (selected.value as OptionValue[]).map(
152151
(value) => props.options.find((option) => option.value === value)!,
153152
);
154153
}
155154
155+
if (props.isMulti && !Array.isArray(selected.value)) {
156+
console.warn(`[vue3-select-component warn]: The v-model provided should be an array when using \`isMulti\` prop, instead it was: ${selected.value}`);
157+
}
158+
156159
const found = props.options.find((option) => option.value === selected.value);
157160
158161
return found ? [found] : [];

0 commit comments

Comments
 (0)