Skip to content
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

Masked values should not be masked when submitted #224

Closed
Chris-Boyle opened this issue Apr 30, 2021 · 2 comments · Fixed by #352
Closed

Masked values should not be masked when submitted #224

Chris-Boyle opened this issue Apr 30, 2021 · 2 comments · Fixed by #352
Assignees
Labels
bug Something isn't working

Comments

@Chris-Boyle
Copy link
Contributor

Chris-Boyle commented Apr 30, 2021

I ran into a scenario where I would like to use a masked field for the phone number value but when the form submits the phone number it is in masked format and not just the digits. I think the masked part should be a UI thing and the value sent in submission should not be masked.

current behavior: value is still masked when sent to the DB "(321) 123-1232"
proposed behavior: value is only masked in the UI and is just numeric when submitted like "3211231232"

Here is what a screen shot of the masked value being submitted in our Storybook
http://localhost:6006/?path=/story/forms-sqform--basic-form-with-masked-fields
image

Current workaround is to strip the non-numeric values when handling the submit

  const handleSubmit = (values) => {
    const phoneNumber = values.phoneNumber.replace(/[^\d]/g, '');
    saveForm(phoneNumber );
  };
@SeanGroff SeanGroff added the bug Something isn't working label Apr 30, 2021
@hvilander
Copy link
Contributor

I have also seen this in the wild. I meant to post this a while back. I have done a bit of digging into this.

Do we only want to strip the masked characters for phone numbers or all masks?

@hvilander hvilander self-assigned this May 6, 2021
@Chris-Boyle
Copy link
Contributor Author

Chris-Boyle commented May 6, 2021

@hvilander I think for most we would want to remove the mask. The ones I think need the mask removed when submitting are phone, zip, currency, percent, and ssn. I think leaving the email mask and date mask is fine.

codyarose pushed a commit that referenced this issue Jul 15, 2021
If `stripNonNumeric` is true it will, on change, set the field's value
to the current input value with all non-numeric characters removed

✅ Closes: #224
SeanGroff pushed a commit that referenced this issue Jul 19, 2021
## [5.1.0](v5.0.3...v5.1.0) (2021-07-19)

### Features

* 🎸 add `stripNonNumeric` prop to `SQFormMaskedTextField` ([c770072](c770072)), closes [#224](#224)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants