reflex icon indicating copy to clipboard operation
reflex copied to clipboard

Input component triggering when hitting enter

Open hwchase17 opened this issue 3 years ago β€’ 4 comments

Is there support for a on_enter or something (similar to on_blur, etc) for the input component?

My desired UX is a user types something, hits enter, and then that triggers some action - is that possible?

hwchase17 avatar Dec 22 '22 20:12 hwchase17

We don't have an on enter trigger as of not but could potentially add this in the future. It is possible to add

Alek99 avatar Dec 22 '22 20:12 Alek99

I think we may need to have to make some sort of pc.form component - then we can do it the same way as React by wrapping your pc.input in a form: https://reactjs.org/docs/forms.html

picklelo avatar Dec 22 '22 22:12 picklelo

Yes we need a on_enter callback to build better user experience.

Or someway to bind a keydown event on the input box? I know the enter key is code 13, and when we detect this, send a event to the backend.

FHU-yezi avatar Dec 23 '22 00:12 FHU-yezi

There is an on enter callback adding this for the next release.

Alek99 avatar Dec 31 '22 08:12 Alek99

Just checking in on the status here. Looks like get_controlled_triggers still only includes {"on_change", "on_focus", "on_blur"}. Is someone working on on_key_press or something like this already?

simonmesmith avatar Jan 31 '23 17:01 simonmesmith

Not yet - I'll add this to the next milestone

picklelo avatar Jan 31 '23 17:01 picklelo

Thanks. Hopefully not too onerous.

simonmesmith avatar Jan 31 '23 18:01 simonmesmith