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

implement submitCount and submitErrors #84

Open
gurgeous opened this issue Dec 26, 2024 · 3 comments
Open

implement submitCount and submitErrors #84

gurgeous opened this issue Dec 26, 2024 · 3 comments
Assignees
Labels
✨ enhancement New feature or request 🛠️ p2-medium Issues that should be addressed but are less urgent ✅ validation Topics involving form validation logic, rules, and error handling. 🌟 ver-minor PR should have a minor version changeset type
Milestone

Comments

@gurgeous
Copy link

Hey logaretm, thanks so much for creating veevalidate and now formwerk. Your efforts are really appreciated :)

Would you consider NOT showing validation errors on blur? Users don't like it when errors appear and disappear, because it makes the form jump around. They lose context. Especially older/slower users, or users seeing something for the first time. Showing errors on blur can be real confusing. Check out the excellent gov.uk form standards:

"When to tell the user about validation errors"
https://design-system.service.gov.uk/patterns/validation/

In my experience the pattern that works best for users:

  1. Disable submit button until all required fields have values
  2. Only show errors on submit (never show any errors prior to submit)
  3. Display fresh errors on next submit (don't change errors while they are working)

I've built zillions of forms across many companies. I even founded a SaaS forms startup. I love forms :) Just an idea since you are still working on the library. Thanks again!

@gurgeous gurgeous added the ✨ enhancement New feature or request label Dec 26, 2024
@logaretm logaretm added the 🧠 think-tank Need to think about this with the core team label Dec 26, 2024
@logaretm
Copy link
Member

Hey, thank you for the suggestions. We do not validate on blur AFAIK, but we validate whenever the value changes regardless.

One thing I learned by maintaining vee-validate is there is no one size that fits all in that area. So in Formwerk, we always validate and we always generate the error, the user decides when it should be shown.

Most of the examples in the docs utilize :user-invalid and :user-valid selectors, which is determined by the browser and not the library. That state is satisfied in chrome by interacting with the input and then blurring it, merely focusing it and blurring it without changing the value should not trigger the selectors.

So I understand how it appears to validate on blur. Maybe there is a mistake in an example in the docs? LMK.

Having said that, I believe the experience you are describing is also desired and is not doable at the moment, and I would like to make it possible to implement.

So I'm thinking about exposing: wasSubmitted and submitErrors which would allow you to build the exact experience you are describing. Would that be suitable?

@gurgeous
Copy link
Author

Thanks for the response! I think I understand and I like the design - separating validation from error display, and leaning heavily on the standard invalid selectors.

You can imagine that it would be somewhat challenging to implement the behavior I described above. I just went through this with a veevalidate form and I had to jump through quite a few hoops...

I like the idea of submitErrors and wasSubmitted. The other one I use sometimes is submitCount, a generation number of sorts that can make it easy to figure out when things change.

Another piece is the concept of required fields. Ideally the submit button would be disabled until all required inputs have a value (even if invalid). Is there a way to get a list of required inputs (good), or a list of values from required inputs (better), or a boolean that tells you whether all required inputs have some value (best)? :P Previously I did this by poking around the schema, but that was rough. I looked at standard schema briefly and I don't think it exposes the concept of required.

@logaretm
Copy link
Member

I like the idea of submitErrors and wasSubmitted. The other one I use sometimes is submitCount, a generation number of sorts that can make it easy to figure out when things change.

Yea, I think we can also expose submitCount. Minimal effort IMO, I may get around to doing it in the weekend. Or if you want, you could create a PR for each state.

Another piece is the concept of required fields...

Formwerk can actually track the required fields the same way it tracks disabled fields, so this is doable as long as the required fields are marked with required attribute.

For schemas, this is a bit challenging because we want to do it through the standard schema spec, this is actually being discussed here, feel free to drop in your perspective.

@logaretm logaretm assigned logaretm and s8n11c and unassigned logaretm Dec 27, 2024
@logaretm logaretm changed the title reconsider validation errors on blur implement submitCount and submitErrors Dec 27, 2024
@logaretm logaretm added ✅ validation Topics involving form validation logic, rules, and error handling. 🛠️ p2-medium Issues that should be addressed but are less urgent 🎯 interactions Tasks or issues related to user interactions, such as focus management or event handling 🌟 ver-minor PR should have a minor version changeset type and removed 🧠 think-tank Need to think about this with the core team 🎯 interactions Tasks or issues related to user interactions, such as focus management or event handling labels Dec 27, 2024
@logaretm logaretm added this to the v1.0 milestone Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request 🛠️ p2-medium Issues that should be addressed but are less urgent ✅ validation Topics involving form validation logic, rules, and error handling. 🌟 ver-minor PR should have a minor version changeset type
Projects
None yet
Development

No branches or pull requests

3 participants