Skip to content

required Validation Not Working When searchable is Set to false #1888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ashish0008 opened this issue Apr 7, 2025 · 0 comments
Open

required Validation Not Working When searchable is Set to false #1888

ashish0008 opened this issue Apr 7, 2025 · 0 comments

Comments

@ashish0008
Copy link

ashish0008 commented Apr 7, 2025

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

  1. Use the <Multiselect> component with :searchable="false" and required inside a form.
  2. Do not select any option and try submitting the form.
  3. 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant