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

add raw value to target #72

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

add raw value to target #72

wants to merge 1 commit into from

Conversation

hosmelq
Copy link

@hosmelq hosmelq commented Oct 13, 2016

Related #69

@aesopwolf aesopwolf mentioned this pull request Dec 15, 2016
@aesopwolf
Copy link
Contributor

@insin do you have any insight on this PR? Seems good to me

@iamdustan
Copy link
Collaborator

@aesopwolf @hosmelq the event object being mutated here with rawValue is a React SyntheticEvent. React uses event pooling and recycles the event objects passed through handlers. This would cause future event handlers to undesirably have a rawValue property.

@iamdustan
Copy link
Collaborator

Bah. I’m mostly wrong. This is mutating the DOM node with an added property. That feels a bit hackish..

@aesopwolf
Copy link
Contributor

I agree, it does feel a bit hackish. Do you know what the downsides are? Or a good alternative?

There's a user-land solution outlined here #58 (comment)

@iamdustan
Copy link
Collaborator

My team hasn’t really had to consider this. We consider the Robustness Principle to carry a lot of weight in form design. Specifically, be liberal in what you accept from others. Masking is a user-experience concern. The server should be liberal in the format it accepts (e.g. it should accept (999) 888-7777, 9998887777, 999.888.7777, +1 (999) 888 7777, etc etc). Masking provides a specific format to communicate expectations to the user. If an API doesn’t accept a specific form then we strip the formatting out when sending the data.

@aesopwolf
Copy link
Contributor

Thanks for sharing that link, I never knew there was a name/label for that idea.

What solution does your team use to "strip the formatting out when sending the data."? Is it just a manual process?

@aesopwolf
Copy link
Contributor

What about setting an attribute data-rawValue on the DOM node itself?

  1. Create a new method getRawValue on the MaskedInput class that returns el.getAttribute('data-rawValue')
  2. Let users setup a ref and call this.refs.input.getRawValue()

@iamdustan
Copy link
Collaborator

@aesopwolf yeah. We have our form validation and cleansing functions together to keep them in sync and just import that at both our UI layer and network layers and run that over the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants