-
-
Notifications
You must be signed in to change notification settings - Fork 7k
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.4.7] Changing :rules of Vuetify Inputs does not affect the validation #18875
Comments
_rules must be reactive.
|
function _rules(additionalrule: boolean) {
if (additionalrule) {
return [isRequired, atleastlength3];
}
return [isRequired]; I made sure to return new arrays and not modify them to avoid reactivity issues in the example of the issue. Because we had to move on in our project we decided to replace the rules evaluation and v-form with our own typescript code and just pass errors to the inputs. Therefore the issue is no longer relevant to us. I'll leave it open to document that the migration was quite effortful and others might arrive at this problem. |
@qxygene: Reactivity seems not to help. We have the same problem in various components and the rules are computed. This is a regression with respect to Vuetify 2. |
This is affecting us also. |
This comment was marked as off-topic.
This comment was marked as off-topic.
Rules are not reactive, This is creating lot of problems. Here the last name is dependent on first name, once first name is filled then last name field should show as a required automatically and it was working in vuetify v2 but now i need to click on submit or focus in and focus out of the last name field to show that field as required. |
Was about to create a similar issue report and stumbled upon this. For another example: see this playground The required rule on the 'First Name' field is only set if the 'Last Name' field has a value. Therefore, clearing the 'Last Name' should remove the error state/message. The error state is removed, but the message still remains |
After extended consideration for this, I'm opting not to make any changes. There are too many potential use-cases for how users are consuming rules that it would overall be better to invoke validation manually. Thank you for your contribution and interest in improving Vuetify! Make sure to join us in the Discord community. |
Environment
Vuetify Version: 3.4.7
Last working version: 2.3.0
Vue Version: 3.4.0-beta.2
Browsers: Chrome 119.0.0.0
OS: Windows 10
Steps to reproduce
Warning: possible duplicate, could be closed because of high complexity, but i've found no workaround to make it work securely in my big application, read other comments
Expected Behavior
Changing the Rules should immediately change the valid status of the form to not allow invalid inputs/confusion of the user. The error message should be immediately displayed.
Actual Behavior
Dynamically replacing the rules array of an input does not trigger a revalidation. This leaves the form valid, until the user revisits the input.
Reproduction Link
https://play.vuetifyjs.com/#...
Other comments
The behavior of showing/hiding the error message on first form input of the user is already very complex. Dynamic rules make this even more complex. Should a changing rule always make the Input immediality show the error or only if its already dirty/has some input? I could'nt test some combinations, because i failed to find/access the
isDirty
/isPrestine
state of the input.I've found #8698 (comment). And tried the
validate(silent: true)
option, which didn't help me because i couldn't find a isDirty state. The<v-validation :rules="[rules]">
is not usable to me because i've found no documentation on how to use it with all the existing variants of inputs, having to write the inputs on my own would make me question the use of the framework for my size of application.Edit: The following snippet is my current wip workaround in my Compontent that wraps
v-text-field
that does not completly work because the way of getting the silent value is not robust/consistent on prisitine/dirty inputs.Edit2: Another Workaround i've found looks like this (⚠️ didn't work consistent for me):
Edit 3: Because we had to move on in our project we decided to replace the rules evaluation and v-form with our own typescript code and just pass errors to the inputs. Therefore the issue is no longer relevant to us. I'll leave it open to document that the migration was quite effortful and others might arrive at this problem.
The text was updated successfully, but these errors were encountered: