Skip to content
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

fix: validate selected items instead of search #15304

Merged
merged 1 commit into from Jun 16, 2022

Conversation

KaelWD
Copy link
Member

@KaelWD KaelWD commented Jun 15, 2022

fixes #15142

<template>
  <v-app>
    <v-container>
      <v-form ref="form" @submit.prevent>
        <v-text-field v-model="text" label="text field" :rules="rules" />
        <v-select v-model="select" label="select" :items="items" multiple :rules="rules" />
        <v-autocomplete v-model="autocomplete" label="autocomplete" :items="items" multiple :rules="rules" />
        <v-combobox v-model="combobox" label="combobox" :items="items" multiple :rules="rules" />

        <v-btn type="submit">Validate</v-btn>
        <v-btn type="reset">Reset</v-btn>
        <v-btn @click="resetValidation">Reset validation</v-btn>
      </v-form>

      <pre>{{ {
        text,
        select,
        autocomplete,
        combobox,
      } }}</pre>
    </v-container>
  </v-app>
</template>

<script setup>
  import { computed, ref, watch } from 'vue'

  const form = ref()
  const items = Array.from({ length: 5 }, (_, i) => `Item ${i + 1}`)
  const rules = [
    v => {
      console.log(v)
      return true
    },
  ]

  const text = ref()
  const select = ref()
  const autocomplete = ref()
  const combobox = ref()

  function resetValidation () {
    form.value?.resetValidation()
  }
</script>

@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected C: VSelect VSelect C: VCombobox VCombobox C: VAutocomplete VAutocomplete labels Jun 15, 2022
@KaelWD KaelWD added this to the v3.0.0-beta milestone Jun 15, 2022
@KaelWD KaelWD self-assigned this Jun 15, 2022
@KaelWD KaelWD merged commit 4eec1d9 into next Jun 16, 2022
@KaelWD KaelWD deleted the fix/15142-select-combobox-validation branch June 16, 2022 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VAutocomplete VAutocomplete C: VCombobox VCombobox C: VSelect VSelect T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant