formsy-material-ui: Validations not working in 0.5.2

Validations stopped working when I upgraded from 0.5.1 to 0.5.2. My form looks like this, when I comment out validations, everything works. Without validations, no cigar. Any ideas?

<Formsy.Form
              ref="form"
              className="form"
              onValid={() => this.enableLoginButton()}
              onInvalid={() => this.disableLoginButton()}
              onValidSubmit={(model) => this.login(user, model)}>
              <FormsyText
                name="email"
                floatingLabelText="Email Address"
                fullWidth
                // validations="isEmail"
                // validationError="Please enter a valid email address"
                {...textFieldStyles}
                required
              />

              <FormsyText
                name="password"
                type="password"
                floatingLabelText="Password"
                // validations={{ minLength: 6 }}
                // validationError="Password must contain at least 6 characters"
                fullWidth
                {...textFieldStyles}
                required
              />```

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 31

Commits related to this issue

Most upvoted comments

I am seeing this also. It has to do with any validations, including “required.” The culprit seems to be line 81 of FormsyText.js, where a "this.resetValue() is called if the field is not valid. This results in weird behaviors such as:

  1. If you have a validation like “isEmail”, and the initial value of the field is blank, typing ANYTHING will be ignored (as the first character is not a valid email address, so the field is reset).
  2. If you have a field marked as “required” and the initial value HAS data and you start backspacing over it, you can remove all but the first character. Once you remove the first character, it becomes “invalid”, it resets, and the old value is put back in place.

I commented out that line in the lib/FormsyText.js of my node_modules dir, and it now seems to be behaving. I don’t know enough about the code to determine if that is a valid fix or just a band-aid.

Thanks @codeaholicguy. Just published 0.5.3

@rojobuffalo (cc @mbrookes) I added you into npm, please check it again

What’s up with the PRs fixing this? Hello @mbrookes ?

Installing joelkoz fork for the time being…

@rmoskal - No, there is definitely a bug that was recently introduced. It just so happens that if you use updateImmediately={true} property, the text control takes a different code path and avoids the validation bug. So, that is a work-around, not a fix.

If anyone is interested, I have a branch on my fork of this project named “current-fixes” which contains the two fixes that I have made to the project. You can check out that branch if you wish to get this working again.: https://github.com/joelkoz/formsy-material-ui/tree/current-fixes

Hey Ryan, good to hear from you! You’re still credited in the README for the original idea. 👍

Thanks to you and @rmoskal for offering to step in. I’ve added you both as collaborators, joining @codeaholicguy who has done great work already! I’ll figure out NPM access when I get a chance (it’s midnight here), but Nguyễn has access for now if you need to publish something.

Thanks again, and shout if I need to do anything else to help with the transition.

Im seeing this too. Seems with validation in the email field it does not allow edit. There are no console errors. Just will not let edit happen. was working for me with 0.5.0 and formsy-react 0.18.1

Just merged several PRs, including those submitted by @joelkoz aimed at fixing this. If we could get some thumbs up on this comment to signal that the @latest is solving this issue, then we can close.