antoniandre / wave-ui

A UI framework for Vue.js 3 (and 2) with only the bright side. ☀️
https://antoniandre.github.io/wave-ui
MIT License
546 stars 41 forks source link

Setting a forms validation value to null does not reset it #93

Closed llamicron closed 2 years ago

llamicron commented 2 years ago

Based on the documentation, it looks like you're supposed to be able to reset a form's validation by programmatically setting it's v-model value to null. This doesn't seem to work. Instead, resetting the HTML form (with something like document.getElementById("...").reset()) works just fine though.

Example:

<w-form id="myForm" v-model="formValid">
    <w-input v-model="value" :validators="[validators.required]">Name*</w-input>
<w-form>
data() {
    return {
        formValid: null,
        validators: {
            required: value => !!value || 'This field is required'
        }
    }
}

In this example, after failing the form validation and getting the error message to appear, setting formValid = null does not clear the validation, making the form pristine. Instead, I needed to reset that value and use document.getElementById("myForm").reset() to reset the form. I also tried running component.$forceUpdate() to see if it just wasn't dynamically updating, but that didn't help.

antoniandre commented 2 years ago

Hi @llamicron, thanks for reporting. This is now fixed in version 2.40.3.

Here's a demo: https://codepen.io/antoniandre/pen/MWVLVEq?editors=101