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

Invoke onKeyDown, onBeforeInput and onPaste handlers from props #67

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

Conversation

Nevon
Copy link

@Nevon Nevon commented Aug 30, 2016

In a product I'm working on, we have some special handling on key presses that extends beyond the scope of the onChange handler. For example, when pressing tab or enter, we want to run some validation. Unfortunately, the masked field does not invoke the onKeyDown that is passed down as a prop, making this impossible.

This change will invoke the passed handlers if they are defined, after running the internal logic for the masked field.

@iamdustan
Copy link
Collaborator

The two examples you provided are supported by browsers out of the box.

Tab -> onBlur
Enter - parent form onSubmit

@Nevon
Copy link
Author

Nevon commented Aug 31, 2016

They are semantically different though. A field can get blurred without the user having pressed tab, and enter can be pressed in a field without submitting the parent form.

You can for example imagine autocompletion where the user presses the down key to select a suggested word or phrase, and then presses tab or enter to have the value be autocompleted. There are lots of situations in which you may want to handle these events within your application, so I don't see any reason why this component would swallow those props.

@Nevon
Copy link
Author

Nevon commented Sep 20, 2016

Any other feedback on this?

@briantrice
Copy link

I am interested in using up and down arrows to increment and decrement digits on a numeric mask. So that 👍 from me, or for that more specific change.

@romanivanyushchenko
Copy link

Will be this pull request accepted?

@binaryjunkie
Copy link

+1, looking to use up/down arrows to increment and decrement numbers, keyDown support would be great.

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.

5 participants