Skip to content

Commit

Permalink
fix(vee-select): make validation work and add error state
Browse files Browse the repository at this point in the history
  • Loading branch information
devCrossNet committed Nov 26, 2021
1 parent 0bea3bd commit 0e81e04
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/forms/FormExample/FormExample.vue
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,14 @@ export default defineComponent({
street: '',
zipCode: '',
city: '',
country: 'de',
country: '',
acceptTerms: false,
newsletter: false,
});
// computed
const countryOptions = computed(() => [
{ label: '', value: '' },
{ label: 'Germany', value: 'de' },
{ label: 'USA', value: 'us' },
{ label: 'Other', value: 'other' },
Expand Down
15 changes: 14 additions & 1 deletion src/components/input-and-actions/VueSelect/VueSelect.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<template>
<ValidationProvider v-slot="{ errors }" ref="validator" :vid="id" :name="name" :rules="validation" tag="div">
<ValidationProvider
v-slot="{ errors, validate }"
ref="validator"
:vid="id"
:name="name"
:rules="validation"
tag="div"
>
<div
ref="selectRef"
:class="[$style.vueSelect, disabled && $style.disabled, errors.length > 0 && $style.error]"
Expand Down Expand Up @@ -50,6 +57,7 @@
:tabindex="disabled ? -1 : 0"
role="listbox"
@click.stop.prevent="toggleMenu"
@blur="validate"
>
{{ inputValueOption ? inputValueOption.label : placeholder }}
</div>
Expand Down Expand Up @@ -298,6 +306,11 @@ export default defineComponent({
background: $select-bg-error;
border: $select-border-error;
}
.nativeSelect,
.customSelect {
background: $select-bg-error;
border: $select-border-error;
}
}
&.disabled {
Expand Down

0 comments on commit 0e81e04

Please sign in to comment.