-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: preserve form input values on custom form validation #91
Conversation
add prop resetOn ('submit' | boolean)
@joshuagraber When I go to test, using the same password in each field, I still get an error. In the console, I'm getting a message about cookies...relevant? edit: the message appears on page load, not form submit |
Hmm, @josh-chamberlain could you share more steps to reproduce? If both inputs contain a matching, valid (per validation currently on Screen.Recording.2024-06-20.at.10.09.53.PM.movNot sure about the cookies, but we're not reading anything cross-site, so it must be something about the dev env. (Edit: or maybe browser extensions. Those can sometimes cause console errors/warnings as well.) (We do want to handle that |
sorry about the delay @joshuagraber ! I get the same behavior whether I use the same password or different passwords. |
@josh-chamberlain No worries. Those are input-level errors, which means these are not valid passwords. The messages aren't super informative (we'll craft better ones for v2), but on this demo it's just dummy validation. A valid password requires: I've just been using Password1! What we're testing here is the form-level errors passed while the calling component validates any extra requirements that we can't handle with our schemas (yet, although that's not a bad idea...) on submission, i.e. that the passwords match. So no input-level errors should be there at all. Otherwise, the form is prevented from submitting. |
|
GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
---|---|---|---|---|---|
9480360 | Triggered | Generic Password | 34b20a0 | src/components/Form/form.spec.ts | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secret safely. Learn here the best practices.
- Revoke and rotate this secret.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
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.
works for me with the appropriate password requirements!
🎉 This PR is included in version 3.0.0-beta.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Background
See #58
Sometimes we will want to do custom validation on form submission. (See the login / signin form in
data-sources
). When this happens, the UX will be better if we preserve the current input values for the user, rather than clearing them on every form submission automatically.Description
resetOn
toForm
of type'submit' | boolean
. If'submit'
is passed, the form clears on submission. Ifboolean
is passed, the form only resets when theresetOn
prop changes totrue
.Form
testsTo test
localhost:8888/sign-up-demo
Password1!
andPassword2!