Conversation
|
I've started reviewing this. |
haacked
left a comment
There was a problem hiding this comment.
Found a bug during my testing. It's in the review.
src/index.ts
Outdated
| private untrackFormInput(form: HTMLFormElement, inputUID: string) { | ||
| let formUID = this.getElementUID(form); | ||
| if (!this.formInputs[formUID]) { | ||
| let formInputs = this.formInputs[formUID] |
There was a problem hiding this comment.
I think this is a little confusing (as evidenced by the bug I point out later). As I understand it, this.formInputs is a way of looking up all form inputs for a form. And formInputs is all the inputs for the current form. So we may want to rename this local variable something like currentFormInputs.
And for extra credit, perhaps this.formInputs should be this.formsInputs or this.forms?
There was a problem hiding this comment.
For now I've applied consistency in usage/naming (formInputUIDs = this.formInputs[formUID]), which (combined with your "use the variable" suggestion) makes the bug more obvious.
A more precise rename (inputsByFormUID?) might be useful, but there are several similar lookup fields we'd want to update for consistency.
Manual validation is no longer debounced: - validateField() - isFieldValid() - validateForm()
These have returned void, so it's not a breaking change. isFieldValid() returns boolean; changing that to Promise<boolean> would be a breaking change, so it's left as-is for now.
|
I did push a fix for the bug Phil found, and rebuilt 0.10.0. |
haacked
left a comment
There was a problem hiding this comment.
Nice work!
Might be nice to include an example of how to clear existing validation messages when you disable validation. But that can happen later.
|
WOW! Nice work! |
|
I'd like to write some docs for the "remove validation" feature. (I'm unfamiliar with the history of the "undebounce" feature, so I'll leave that for another day or another person.) Comments:
Questions, I want to know whether I understand the new behaviour:
Anything else I need to know? (Sorry for the long list of questions. The new bits are really useful, thanks!) |
|
@lonix1 Great questions! Would you mind opening a new issue with these questions? New questions on a closed PR are easy to overlook. 😄 |
|
Sorry I thought opening a new issue would be spamming your repo. :) I've done so here: #114 |
More than I usually like to change at once, but all interrelated. In particular:
validateForm()andvalidateField()have been changed from returningvoidto returningPromise<boolean>, resolving with the same value theircallbackwould receive.