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

[Bug Report][3.5.9] The first form entry will not be validated if the form is reset and validated at the same time #19399

Closed
kschwedler opened this issue Mar 14, 2024 · 4 comments
Assignees
Labels
C: VForm VForm T: bug Functionality that does not work as intended/expected
Milestone

Comments

@kschwedler
Copy link

Environment

Vuetify Version: 3.5.9
Vue Version: 3.4.19
Browsers: Chrome 122.0.0.0
OS: Windows 10

Steps to reproduce

Expected Behavior

All fields are in an error state

Actual Behavior

All fields are in an error state except the first input

Reproduction Link

https://play.vuetifyjs.com/#...

Other comments

When filling out the wrongly validated form, it is possible to submit the form with an empty first input when the form doesn't get validated after pressing submit

@b-maslennikov
Copy link

b-maslennikov commented Mar 14, 2024

try

import { nextTick } from 'vue'

resetAndValidate() {
    this.$refs.form.reset()
    nextTick(async () => await this.$refs.form.validate())
}

playground

@kschwedler
Copy link
Author

try

import { nextTick } from 'vue'

resetAndValidate() {
        this.$refs.form.reset()
        nextTick(async () => {
          await this.$refs.form.validate()
        })
      }

playground

Wow that was fast, works for me!
But in general my example should work right?

@b-maslennikov
Copy link

b-maslennikov commented Mar 14, 2024

i dunno
but it stopped working in 3.3.0 (almost year ago)

@KaelWD KaelWD added T: bug Functionality that does not work as intended/expected C: VForm VForm labels Mar 22, 2024
@KaelWD KaelWD self-assigned this Mar 22, 2024
@KaelWD KaelWD added this to the v3.5.x milestone Mar 22, 2024
@KaelWD KaelWD closed this as completed in 800b0c5 Mar 22, 2024
@KaelWD
Copy link
Member

KaelWD commented Mar 22, 2024

Reset is also asynchronous, it uses nextTick itself between clearing the value and re-running validation. The correct way to do this will be

await this.$refs.form.reset()
await this.$refs.form.validate()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VForm VForm T: bug Functionality that does not work as intended/expected
Projects
None yet
Development

No branches or pull requests

3 participants