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

Manual validation mode #7902

Open
vursen opened this issue Oct 2, 2024 · 3 comments
Open

Manual validation mode #7902

vursen opened this issue Oct 2, 2024 · 3 comments
Labels
DX Developer experience issue enhancement New feature or request validation

Comments

@vursen
Copy link
Contributor

vursen commented Oct 2, 2024

Describe your motivation

Automatic constraint validation on every field change isn't always suitable. Consider these cases:

  • Forms that should validate only on submit
  • Fields with externally controlled invalid states

Describe the solution you'd like

For such cases, a manual validation mode (similar to that in Flow components) would be beneficial. It would disable the automatic validation but leave the option to trigger it programmatically by calling the validate() method, or alternatively, control the invalid state completely manually.

Here is how the API could look like:

<vaadin-text-field manual-validation />
@vursen
Copy link
Contributor Author

vursen commented Oct 2, 2024

LoginForm is a potential candidate to use this feature. Triggering validation only on submit could help avoid content shifts currently caused by automatic validation, see #7894 (comment)

@sissbruecker
Copy link
Contributor

This might also be a proper solution for Flow components to disable client-side validation. Currently we override the _shouldSetInvalid method to always return false so that a web component never updates its invalid state. Disabling automatic validation in the web component should have the same effect and is easier to accomplish by setting an attribute or property. We need to make sure that no Flow component relies on the validated event anymore, which is still triggered with the current approach, but would not be triggered anymore when disabling automatic validation.

@vaadin vaadin deleted a comment from lakshyeahh Oct 3, 2024
@web-padawan
Copy link
Member

Prototype branch with validate() method calls replaced with _requestValidation() which checks for manualValidation property: https://github.com/vaadin/web-components/compare/proto/manual-validation

Note: if we decide to also use this in Flow like suggested above, we might also need to replace _setInvalid() method usage (and maybe get rid of it completely as it's only used in ValidateMixin and InputConstraintsMixin).

@yuriy-fix yuriy-fix added DX Developer experience issue validation enhancement New feature or request labels Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Developer experience issue enhancement New feature or request validation
Projects
None yet
Development

No branches or pull requests

4 participants