Open
Description
Title: required
Validation Not Working When searchable
is Set to false
Description
I encountered an issue where the required
validation does not work when the searchable
prop is set to false
. By default, searchable
is true
, and the required validation works as expected. However, when I explicitly set searchable: false
, the component allows form submission even when no option is selected.
Steps to Reproduce
- Use the
<Multiselect>
component with:searchable="false"
andrequired
inside a form. - Do not select any option and try submitting the form.
- The form submits successfully, even though it should prevent submission due to the required field.
Expected Behavior
The required
validation should work regardless of whether searchable
is true
or false
. If no option is selected, the form should not be submitted.
Actual Behavior
When searchable
is false
, the required
validation is ignored, and the form submits without any errors.
Reproducible Example (if applicable)
<template>
<form @submit.prevent="submitForm">
<multiselect
v-model="selected"
:options="['Option 1', 'Option 2']"
:searchable="false"
required
placeholder="Select an option"
/>
<button type="submit">Submit</button>
</form>
</template>
<script>
import Multiselect from "vue-multiselect";
export default {
components: { Multiselect },
data() {
return {
selected: null,
};
},
methods: {
submitForm() {
alert("Form submitted! This message should display only if option is selected");
},
},
};
</script>
Environment
- Vue: 3.5.13
- vue-multiselect: 3.2
- Browser: Chrome v134
Metadata
Metadata
Assignees
Labels
No labels