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(VCheckbox): fix show correct color in error state #19286

Merged

Conversation

SonTT19
Copy link
Contributor

@SonTT19 SonTT19 commented Feb 27, 2024

Description

fixes #19127

Markup:

<template>
  <v-sheet width="300" class="mx-auto">

    <v-form ref="form">
      <v-text-field
        v-model="name"
        :counter="10"
        :rules="nameRules"
        label="Name"
        required
      ></v-text-field>

      <v-select
        v-model="select"
        :items="items"
        :rules="[v => !!v || 'Item is required']"
        label="Item"
        required
      ></v-select>

      <v-checkbox
        v-model="checkbox"
        :rules="[v => !!v || 'You must agree to continue!']"
        label="Do you agree?"
        required
      ></v-checkbox>

      <div class="d-flex flex-column">
        <v-btn
          color="success"
          class="mt-4"
          block
          @click="validate"
        >
          Validate
        </v-btn>

        <v-btn
          color="error"
          class="mt-4"
          block
          @click="reset"
        >
          Reset Form
        </v-btn>

        <v-btn
          color="warning"
          class="mt-4"
          block
          @click="resetValidation"
        >
          Reset Validation
        </v-btn>
      </div>
    </v-form>
  </v-sheet>
</template>

<script setup>
  import { ref } from 'vue'

  const form = ref()

  const items = [
    'Item 1',
    'Item 2',
    'Item 3',
    'Item 4',
  ]

  const name = ref('')
  const nameRules = ref([
    v => !!v || 'Name is required',
    v => (v && v.length <= 10) || 'Name must be less than 10 characters',
  ])
  const select = ref(null)
  const checkbox = ref(false)

  async function validate () {
    const { valid } = await form.value.validate()

    if (valid) alert('Form is valid')
  }
  function reset () {
    form.value.reset()
  }
  function resetValidation () {
    form.value.resetValidation()
  }
</script>

@MajesticPotatoe MajesticPotatoe added T: bug Functionality that does not work as intended/expected C: VCheckbox VCheckbox labels Feb 27, 2024
@johnleider johnleider added this to the v3.5.x milestone Feb 29, 2024
@johnleider johnleider merged commit 7029f06 into vuetifyjs:master Feb 29, 2024
10 checks passed
VIXI0 pushed a commit to VIXI0/vuetify that referenced this pull request Mar 13, 2024
fixes vuetifyjs#19127

Co-authored-by: Son Tran <stt@cct-technology.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VCheckbox VCheckbox T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug Report][3.5.1] VCheckbox label should have the error color when has the error state
3 participants