- Add more detailed examples of how to use
Zod
with thedefaultErrors.validate
option. - Figure out a Logo for the
enthusiastic-js
Organization and maybe the Form Observer package? - In the interest of time, we're probably going to have to do the bare minimum when it comes to the documentation. Make the API clear, give some helpful examples, etc. After we've release the first draft of the project, we can start thinking about how to "perfect" the docs. But for now, don't get too paranoid about the wording.
- We currently have StackBlitz examples for the
FormValidityObserver
. Would examples for theFormObserver
or theFormStorageObserver
also be helpful?
- PRIORITY Consider automating the process of publishing NPM Packages (with provenance) using GitHub Releases.
- Seriously. This seems super easy. You should definitely do/try this the next time you release a new package version.
- For the
build-packages.js
script, you might need to conditionally copy GitHub CI's.npmrc
file to all of the workspace folders. This logic would be added to theaddNPMFilesTo()
function. (The condition is that this should only happen on CI. You can check GitHub CI'sprocess.env.CI
environment variable for this.) Then you can trynpm publish --workspaces --provenance --access=public
(after running the build script). But if you're unsure about how reliable the--workspaces
option is, perhaps you can try looping through the folders on CI instead? (Let's hope that--workspaces
works just fine...)
- Consider adding some badges to our Repository's homepage (e.g., Test Coverage).
- Maybe we should have a "potential pitfalls" or "pro tips" section?
- For example, anyone who extends the
FormObserver
should probably use arrow functions for event handlers if they ever want to usethis
... It will make life much easier. Then again, don't developers who are trying to usethis
already know that? 🤔
- For example, anyone who extends the
- Should the
ValidationErrors
interface reference the classic form field attributes, or theValidityState
properties? Using the regular form field attributes is great if you're using regular HTML Elements. But it might be a little less intuitive for those using Custom Elements. (There are also downsides to shifting our approach. So this would require some thinking.) EDIT: This probably isn't a concern. However, for frameworks that handle attributes in an unorthodox way likeReact
, we might have to think of a solution that takes care of both regular fields and Custom Elements. Regular JS frameworks like Svelte, Vue, and Solid will not have this problem. - The
aria-describedby
attribute technically supports multiple IDs at one time. Should we add adata-describedby
(ordata-errormessage
) attribute for cases like these? We would need to enforce that thedata-errormessage
value is a substring of thearia-describedby
value in this case (so that the error message is still accessible). However, it's hard to say how realistic this scenario would be. Anyone attempting to do this would also have to deal with the fact that the various descriptions would get joined together into a "single unit"... So they'd have to be mindful of the order of theiraria-describedby
ids anyway. This might be worth tackling, but it doesn't seem urgent; so we're delaying it. - It's a little bothersome to us that in the
validateFields()
method,getErrorOwningControl
technically has to be called twice when scrolling an invalid field into view. It's not the end of the world, but it doesn't feel like a clean solution either. This might be another reason to migrate towards checkingfield.validity.valid
instead offield.getAttribute("aria-invalid") === String(true)
. (This would require passingerrorElement.innerText
/errorElement.textContent
tosetCustomValidity
whenever we use therenderer
function to render error messages to the DOM.)
- Would it make sense to make the
FormValidityObserver
its own class? It may not need to extend theFormObserver
at all since it only supports watching 1 form at a time... - Is there a way that we could call
form.checkValidity()
if none of the fields have a configured customvalidate
function? Would that be a meaningful performance boost -- if any? (If we did that, we might also need to add acapture
dinvalid
event handler to make sure error messages are properly updated if needed.)- Note: It may be sufficient/appropriate to delegate this to user land. Perhaps we could simply add documentation saying, "For a performance boost, if you don't have any custom
validate
functions, just useform.checkValidity()
" or something like that. (This, again, is assuming thatform.checkValidity()
yields a significant performance boost overobserver.validateFields()
. We need to test that.) If we go with this approach, we'd probably still need to registerinvalid
event handlers. So we need to think about how we'd go about that if we want to go that route.
- Note: It may be sufficient/appropriate to delegate this to user land. Perhaps we could simply add documentation saying, "For a performance boost, if you don't have any custom
- Are there any ways that we can optimize updating the DOM? (For instance, not touching
element.textContent
if the error message didn't change. Is there even a significant performance benefit in doing that?)
- Provide a way for users to specify the value of
aria-invalid
(e.g.,spelling
). Maybe we could do this through theValidationErrors
configuration? (Note: This idea might not even be significant or truly needed.) - Perhaps we should dispatch the
invalid
event when validation fails? Just like the browser does? If we're claiming to enhance the browser's functionality, then we don't really want to take away anything that the browser does. Instead, we want to add to it (as effectively, powerfully, and minimalistically as possible). Edit: We won't be supporting this any time soon unless people explicitly request it. See our Development Notes - Currently, we technically allow developers to do both accessible error messaging and native error messaging simultaneously. It isn't encouraged, but it might be helpful for developers transitioning from one mode to another. Even so, this could be a source of confusion. This already makes our code a little confusing sometimes (potentially) since we effectively determine whether or not a field uses accessible errors based on its
aria-describedby
attribute. If we had an option for theFormValidityObserver
constructor that let the developer determine whether they were using accessible errors or native errors from the start, that could potentially be more useful/clear... It would at least be more helpful from a maintainability standpoint... well, potentially. Is it worth trying? Or not? - Consider adding a
silent: boolean
option to thevalidateField()
andvalidateFields()
methods. Perhaps there are some people who want to be able to validate their field(s) manually without displaying the error message(s) to users? We don't know how common that use case is... But this feature would provide greater alignment with methods likefield.checkValidity()
andform.checkValidity()
, which avoid generating noise for users. (Ideally, we'd want developers to be able to use enhanced versions of bothfield.reportValidity()
/form.reportValidity()
andfield.checkValidity()
/form.checkValidity()
so that they don't "lose" any browser features.)- Note: For what it's worth, as long as developers aren't using custom validation functions,
field.checkValidity()
andform.checkValidity()
are perfectly fine to use on their own. We don't need asilent
option for that use case. Thesilent
option would only be relevant for developers who want silent validation and who use custom validation functions. Otherwise, the browser's methods are enough.
- Note: For what it's worth, as long as developers aren't using custom validation functions,
-
Critical
: Figure out what to do about the broken, overloaded generic constructor types for theFormObserver
(and its children) -- specifically surrounding generic event types. This seems to be a bug in TypeScript, though it might be intentional since generic constructors are not allowed in.ts
files at all... We don't want to rewrite our code again, and it seems a little difficult to create separate.d.ts
files for the generic constructors (if our plan is to cast all of the default exports of classes to the constructorinterface
s). So... We'll wait and see if the TypeScript team will update anything for now. See microsoft/TypeScript#55919 and microsoft/TypeScript#40451. At least all of the other types in our project are good, though! :D And those are the more important types! Plus, if people are using the Framework Integrations, they'll have all the types that they need anyway (at least for form field validation). So... it should be safe to release our package right now.
- Figure out why
@solidjs/testing-library
isn't able to render raw elements correctly for testing. - It's weird that
beforeEach(vi.restoreAllMocks)
causes an error in TS. Maybe that ought to be a GitHub issue? - Temporarily, we have to change
userEvent
to a named import because of testing-library/user-event#1146. Hopefully this gets fixed eventually. Maybe we can contribute something if we figure out thisNodeNext
headache on our own end. (I think that we did indeed figure it out.)