-
Notifications
You must be signed in to change notification settings - Fork 25
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
Do not validate disabled fields #94
Conversation
I noticed that when a disabled element is valid, we mark it green. We should completely ignore disabled elements. I'll dig into this a bit more. |
455e75b
to
98b4a3e
Compare
Co-authored-by: Keith Dahlby <[email protected]>
5d4cc4f
to
52446b9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We ended up not using watch: true
. I think we should try to make this work as expected without.
The demo would re-validate the input in updateStatus()
to handle the reset - if a form has enabled/disable behavior I don't think that's too much to ask.
I think we should have two demos. It should Just Work™️ if |
This can be called after changing the state of a form input.
Ok, try that out and let me know what you think. |
@dahlbyk do you want to take another look or should I go ahead and merge? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well I apparently had some pending comments, so let's start there? 😅
This way, if they become enabled, we'll validate them. If they become disabled, we won't validate them.
I made some changes thanks to @dahlbyk's feedback. His feedback made me realize that ignoring validation on a disabled field is orthogonal to whether we update the input's current validation state when it is enabled/disabled. So we never validate a disabled input. We always validate an enabled input. However, if an input is currently enabled and showing a validation error and you dynamically disable the input, the validation error will continue to be displayed. But the next time you submit the form, the field will be ignored and the validation message will be cleared. If you want the validation message to be cleared at the time the input is disabled, there's two options:
I've included demos of both. |
`as` in TypeScript is not the same as in C#.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't kick the tires, but the changes align with what I had in mind. 👍
Fixes #90
Note this does not handle disabled fieldsets because we just rely on the browser for that. If that assumption is incorrect, we can fix that in a subsequent PR.