Skip to content

Commit

Permalink
Merge pull request #27 from platanus/fix/listbox-only-vee-validate
Browse files Browse the repository at this point in the history
fix(): use value from vee validate instead modelValue
  • Loading branch information
fprebolledo authored Aug 16, 2023
2 parents 9f4eda2 + 5286c85 commit 80a3864
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/components/BnListbox/BnListbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function isMultipleValue(value: InputValue | InputValue[]): value is InputValue[
const emit = defineEmits<{
(e: 'focus', event: Event): void,
(e: 'blur', event: Event): void,
(e: 'update:modelValue', value: InputValue | InputValue[]): void,
}>();
const { name, rules } = toRefs(props);
Expand Down Expand Up @@ -117,14 +118,14 @@ function unparseValue(value: InputValue | InputValue[]) {
return value;
}
const parsedValue = computed(() => parseValue(props.modelValue));
const { handleChange, value, meta, setTouched, errorMessage } = useField<InputValue | InputValue[]>(name, rules, {
initialValue: props.modelValue,
initialValue: !props.modelValue && props.multiple ? [] : props.modelValue,
validateOnMount: true,
syncVModel: true,
});
const parsedValue = computed(() => parseValue(value.value));
const listboxButtonRef = ref<ComponentPublicInstance>();
const {
width: listboxButtonWidth, top: listboxButtonTop, left: listboxButtonLeft,
Expand Down Expand Up @@ -180,7 +181,7 @@ function blur(e: Event) {
<template v-if="!props.keepObjectValue">
<template v-if="props.multiple">
<input
v-for="(val, idx) in modelValue"
v-for="(val, idx) in value"
:key="idx"
:value="val"
type="hidden"
Expand All @@ -189,7 +190,7 @@ function blur(e: Event) {
</template>
<input
v-else
:value="modelValue"
:value="value"
type="hidden"
:name="name"
>
Expand Down

0 comments on commit 80a3864

Please sign in to comment.