-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
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
TextField detect enter (or other) key #5393
Comments
Just some though. How would you solve this issue with an |
I think it's weird to say it's not related to material design. It's an essential part of interaction with the textfield component and that's the main point of material, to make it easy to have a good user interaction. Why didn't you also remove onChange and onKeyDown then? @BlockChange I solved it previously with an |
That would prevent users from implementing this logic on their side. I believe that we should aim for a |
The problem right know is that every developer is left alone with this problem. It would be really cool if there would be FAQ with code snippets for such things or a registry specially for material-ui for developers which developed such HoC's already. So they can share these ones with us. Regarding the native input: A native input has an on enter function. When the enter key is hit the form will be sent. But in React it seems uncommon to place forms around input fields. So there needs to be an easy mechanism for developers to implement on enter behaviour because it such a "core" user interaction. |
I can't make is work. Any idea http://www.webpackbin.com/N1SoP8i1G?
React allow you to more or less get away without using it. But I still think that it's a best practice to use it.
I agree, but I'm not aware of any project addressing this issue. |
Hey guys;
Worked for me. Note the Cheers! |
I would love a less verbose alternative to @SuEric's solution. Would it be feasibly to turn this into an onEnter callback? |
@AdityaAnand1 This is like, five lines of code, using the super non-verbose arrow functions... Also, what about other keys, we'd have an onLetterD, onEsc and onLeftParens? I'm all for laziness, but there are limits ;) If it's the number of arguments for the TextField that bother you, it's always possible to implement the method as a class member, and use
|
@Zvax has summed it up nicely, so to save further debate, I'm going to lock this issue. |
Before there used to be an
onEnter
available if I remember correctly, but it got removed. However, I don't know how to detect an enter event now, because if I press enter, theonChange
is not fired...I must be missing something, but in the docs I don't see any other method to use to detect if enter was pressed...
The text was updated successfully, but these errors were encountered: