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
Added some missing form validation standard features (implemented for #1181) #1167
Conversation
… to all nine form controls
… the form controls
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
I didn't have time to test this today, but I reviewed the code and don't see anything that concerns me. If it works, I'm OK proceeding. I would suggest moving |
Note to myself: make sure to add an example of this (i.e. custom inline validation) to the docs. |
@claviska Just to make sure, I will inform you as soon as there's something to see/test/review/whatever here - currently there's nothing really finished to be tested (as things have changed a bit). Would otherwise just be a waste of time for you. |
@claviska Okay, thanks. Done and available as preview. Please be aware that I've not yet removed my previous inline validation demo (marked as Current status of this task: Everything finished and commited except for the tests. |
Thanks for the update. We'll need to revisit that example to make sure it's accessible. Since the error message is in an I'm happy to help with this. If all we're waiting on is tests, let's finish that up and then we can tackle a11y. |
I would prefer to clarify this asap as long as you are available today (the tests can wait). If this is not an option, then another option would still be this "1% not-userland" solution where we would have to add this snippet to each SL form control (+ some a11y stuff): To be placed below the <div part="form-control-validation-message" hidden>
${this.validationMessage}
</div> Would make things in userland much simpler (literally a handful lines of JS + some more handsful of CSS). I'm open for any other suggestions of course 😉 |
[Edit] Removed silly proposal with |
It has to map to an element as shown here. <p>
<label for="email">Email address:</label>
<input
type="email"
name="email"
id="email"
aria-invalid="true"
aria-errormessage="err1" />
<span id="err1" class="errormessage">Error: Enter a valid email address</span>
</p> So it would need to be applied to the internal input and point to a container that holds the error message. This is exactly how aria-describedby works, for reference. Without modifying any internals, you can probably get away with |
LOL, at least I should read the first sentence of web pages before posting links to them 😄 . Thanks for the clarification. |
Or use the browser's built-in validation and get it all for free! 🙃 I joke, and I'd like to support this use case. The more long-winded response is that this would be easier to do in userland if we had a way to poke through the shadow DOM and assign In the meantime, we can still make this work. However, it will entail injecting a container into the shadow DOM. This is a bit dirty, but we can rely on the consistent structure of form control parts. Essentially, Shoelace will use the browser's constraint validation mechanism by default and, if you want inline errors, you'll need to cancel the Again, I'm more than happy to help out with this. Let me know what you think. |
Frankly, I would be really thankful if you could implement that inline validation stuff the way that you have described above ❤️ ... my automatic tests for that validity stuff turned out to be toooooo good 😉, reported some additional bugs - grrrrrr... so I'm happy if I can concentrate on these bugs first. Do whatever you like to do with this
😄👍 |
Then you could easily give it a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks really good. I'm pulling it in so I can polish a few things up and work on an updated inline validation example.
Thank you!
The following form handling standard features have been added:
validationMessage
andvalidity
invalid
eventsPlease let me know what you think of this draft. Thanks.
PS: This PR was previously meant for #1163, but it's now dedicated to #1181 - sorry for the chaos