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 preprocessValue callback, just to allow users to change value a… #115

Closed
wants to merge 1 commit into from

Conversation

brunops
Copy link
Contributor

@brunops brunops commented Apr 28, 2016

…s they type

  • This is useful to do normalizations, like transforming japanese numbers (e.g., 1, 2, etc.) to the right alpha numbers (e.g., 1, 2, etc.).
  • I wasn't able to change anything as the component seems to completely manage its own state and it doesn't take defaultValue property.. directly changing value makes the cursor jump like crazy.
  • I tried adding a test for this, but Simulate.change and Simulate.keyDown

…s they type

- This is useful to do normalizations, like transforming japanese numbers (e.g., 1, 2, etc.) to the right alpha numbers (e.g., `1`, `2`, etc.).
@coveralls
Copy link

coveralls commented Apr 28, 2016

Coverage Status

Coverage increased (+0.5%) to 92.388% when pulling 3e3ba64 on brunops:preprocess-value into 0d18e74 on patw0929:master.

@janmarek
Copy link
Contributor

directly changing value makes the cursor jump like crazy

I think this is the real issue. IMO normalization should be done by saving fixed value and passing it as value prop.

@brunops
Copy link
Contributor Author

brunops commented Apr 29, 2016

@janmarek I meant passing value directly makes the cursor jump very weirdly, not only to the end, but very odd behavior, probably because the component is managing its own state internally. Not sure if it's related to the fact that utilsScript already does formatting (cursor already jumps even on demo page, but a "normal jump").

For the use case I mentioned, the preprocessValue part makes the component work as is.

@brunops
Copy link
Contributor Author

brunops commented May 3, 2016

@patw0929 any thoughts on this?

@patw0929
Copy link
Owner

patw0929 commented May 4, 2016

Hi @brunops
Sorry, I'm busy at my work recently. 😲 😲 😲
Have a not carefully thought here, maybe the "normalization" can be a build-in feature, and handling in TelInput's keydown event?

@brunops
Copy link
Contributor Author

brunops commented May 4, 2016

Oh, no problem man.

I wouldn't add normalization as part of the plugin itself, I think providing a callback where people can process the input any way they want to is more flexible (most people will probably never use this).

@patw0929
Copy link
Owner

patw0929 commented Jun 2, 2016

Sorry for being busy so long... 😭


I'm curious about the need of normalizations. Because we already restrict the input keys in 0 ~ 9 & + in handleKeyPress function, so users should not have any chance to key in full width numbers like , , right?

@brunops
Copy link
Contributor Author

brunops commented Jun 2, 2016

@patw0929 no worries man!

You are correct, the problem appears when full width numbers need to be allowed, in a way that instead of when typing , instead of showing nothing, would actually show 1. Let me know if that's clear

@mcataford
Copy link
Collaborator

Going to close this due to age, not opposed to revisiting the underlying changes / ideas though!

@mcataford mcataford closed this Mar 18, 2020
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.

None yet

5 participants