-
Notifications
You must be signed in to change notification settings - Fork 288
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 an on_enter handler for input type components #296
Add an on_enter handler for input type components #296
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall - looks good, if you could add a test, that would be great. thanks.
14a6035
to
8933fd3
Compare
I originally wrote a comment suggesting an alternative approach of @richard-to WDYT about the API here? |
I was thinking that we'd have something more generic and similar to what's available on the Javascript side, which would be on key up. But that's a great point about on_input. On key up and on input are not technically the same. It sort of feels like a on compromise of on key up/press/down in some ways. I do wonder if it would be possible to pass in modifier keys and key presses like enter with on_input. For example, it's possible we could pass in a list of the modifier keys and key presses. I think that is possible, but due to the necessary debouncing and latency, I'm not sure how easy to use it would be from an API usage standpoint. So do I think the proposed hot key idea could work more generically. I think the on_enter is still very useful since it is a common use case. So eventually could be seen as a shortcut for whatever hot key implementation. Maybe one suggestion feature-wise could be support the also common "Modifier" + Enter use case that Will mentioned. But I think that could be added on later to the current api if necessary. |
OK sounds good, let's go with this |
@orangerd you'll need to fix a pre-commit issue. BTW you can install the pre-commit hooks to catch it locally, see: https://google.github.io/mesop/internal/development/#commit-hooks |
12d6d69
to
93a897d
Compare
Allow an on_enter handler for input types so that input boxes can be 'submitted' using the keyboard.
93a897d
to
9f8fb3c
Compare
Ah sorry - yes installed the pre-commits |
Thanks! Merging |
Allow an on_enter handler for input types so that input boxes can be 'submitted' using the keyboard.
Add an
on_enter
handler for<input type="text">
type components, so that input boxes can be "submitted" using the keyboard. Currently, there's no handler for "Enter", so input boxes are usually "submitted" using a relevant button hooked to a handler.