-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
<PasswordInput/>
or <TextInput/>
has corrupted validate
prop, if field is handled with disabled
prop
#9753
Comments
<PasswordInput/>
or <TextInput/>
has corrupted validate
if field is handled with disabled
prop<PasswordInput/>
or <TextInput/>
has corrupted validate
prop, if field is handled with disabled
prop
Hi @silversonicaxel, I'm not sure to understand when, where or how you want to use this code snippet. Could you apply it a Stackblitz please |
@erwanMarmelab here my example: If you go to that link, follow the steps to see the two behaviours I am mentioning:
Wrong implementation (missing the disabled password prop), without the bug Correct implementation (with the disabled password prop), but WITH the bug I hope things are more clear now. |
Confirmed, thanks for the report. For the moment, you can validate your edit page by adding a form validation like this: const validatePost = values => {
const errors = {};
if (values.activator && values.password.length < 8) {
errors.password = 'Password at least 8 characters';
}
// other validations...
return errors;
};
const PostEdit = () => {
...
return (
<Edit>
<TabbedForm validate={validatePost}>
...
</TabbedForm>
</Edit>
);
}; |
Thanks! |
I can't reproduce the problem in v5 (see https://stackblitz.com/edit/github-eqexed-xqlck5?file=src%2Fposts%2FPostEdit.tsx). So my advice is to upgrade to v5 to get this fixed. I'm closing the issue, but feel free to comment if you manage to build a repro for v5. |
What you were expecting:
A
<PasswordInput/>
is activated with a toggle that basically handle the password fielddisabled
prop. If toggle is not active,<PasswordInput/>
is disabled, otherwise enabled. The password field has avalidate
prop, that defines a rule for the field. Rule is minimum 8 characters. If not respected, a red error occurs.Clicking saving button I expect to submit the form, with or without password enabled, and if enabled with password longer at least 8 characters.
Clicking saving button I expect not to submit the form, with password enabled and password length shorter than 8 characters.
What happened instead:
With toggle enabled, password enabled and the password min length validation rule in place, I type a wrong password, long 3 characters.
I submit the form with password rule not respected. The
validate
prop is ignored, form is submitted anyway.If the
disabled
prop is never set in<PasswordInput/>
,validate
prop works as expected.Steps to reproduce:
Activate toggle for password field, type a short password, submit the form.
Related code:
Other information:
No error occurs after clicking save button
Environment
The text was updated successfully, but these errors were encountered: