You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using an async validator, text inputs can experience stuttering while typing. For example, displaying an error when a username is already taken requires making a request to see whether the inputted username is valid or not. I'm not sure what the exact cause is, but it makes it very hard to use async validators.
A potential fix could consist of either debouncing any async validators or canceling any pending promises in favor of evaluating a newer one. For now, I'll just use external validation on the input to check if the username is taken or not.
The text was updated successfully, but these errors were encountered:
@chainlist, it would be awesome to have a specific place for async inside validators so we don't mix things together. The svelte/forms is pretty similar to @angular/forms and maybe the same approach is the best approach (or you can use some tricky magic to see if something is async or not in the same array and do it better).
in @angular/forms we often use this:
myForm = formBuilder.group({
myField: ['Initial Value ', [/* space for validators */], [ /* space for async validators */] ];
And yes, they're debounced and it works pretty well. If you want some help with it I'm happy to contribute. I love svelte and this is by far the best
the docs say that you should bind the value to the variable but for some reason it will change the value in the input field back to the last known value that has been checked, which causes the problem I believe.
When using an async validator, text inputs can experience stuttering while typing. For example, displaying an error when a username is already taken requires making a request to see whether the inputted username is valid or not. I'm not sure what the exact cause is, but it makes it very hard to use async validators.
A potential fix could consist of either debouncing any async validators or canceling any pending promises in favor of evaluating a newer one. For now, I'll just use external validation on the input to check if the username is taken or not.
The text was updated successfully, but these errors were encountered: