-
Notifications
You must be signed in to change notification settings - Fork 116
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
forms immediate server side validation #1672
Conversation
🦋 Changeset detectedLatest commit: 3fd3217 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
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.
Yasss! 🎉 Just a few minor things.
Oh, this is neat! Was there an issue tied to this effort? Curious if we involved Primer accessibility design in the decisions about how the client-side validations appear in the form. |
@lesliecdubs good questions! There's no tracking issue to my knowledge. This work came from one of the settings page forms @neall's been working on. It so happens I also need it for the billing upgrade form.
We have not explicitly sought their input, however the markup and behavior adheres to the existing form interface guidelines. I believe they have been a11y reviewed, although I may be wrong about that. In any case, we do need to have someone from a11y look at this. We probably need to announce the validation message somehow. |
53228a3
to
683c2b4
Compare
f9431ec
to
21c6f3c
Compare
81efead
to
025d7c0
Compare
05b5421
to
5bad56d
Compare
44ee351
to
e3a9f01
Compare
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 sets up a place to test form text fields that will automatically validate against the server. It makes tests around the existing text field functionality without the auto-server-validation. I pulled out the DeepMind fake model from an existing test file in order to share it with this new test file.
This will allow us to validate a text field against the server with JavaScript using custom elements.
When we show the validation elements, only include the data-target attributes when we need them.
We decided that `text-field` was a bit too generic a name for the global custom element namespace on a page.
Prevent PrimerTextField event handlers from hanging around in weird cases. Co-authored-by: Keith Cirkel <keithamus@users.noreply.github.com>
We were only deploying lib assets under `lib/postcss_mixins`, but now we have JavaScript coming from the lib directory as well.
The underlying functionality is tested somewhere else, and these example forms are not used in the built gem.
Terser seems to be eliminating debugger statements during minification and we couldn't figure out why. For now, if you want to use the debugger in development you can comment out the line that adds the Terser plugin to Rollup.
c352bf6
to
33acbe2
Compare
Description
This adds optional client-side functionality to Forms framework text fields so they can validate against the server as the user types.
I had to touch a lot of lines in
form_control.html.erb
, so I wrapped that in some more tests. There's still a lot of logic in that file but I moved some of it into other places where it is easier to read.In particular that file is where we render the error-message-related elements. We normally don't render them if there is no error on the field, but if we are using auto-check and updating the client we need to render those elements hidden.
Integration
This won't require any changes to existing forms; nothing changes unless the developer specifies a URL for
auto_check_src
on their text field.Merge checklist