TextInput: onEnterPressed & onChange behave differently
I’m trying to use a TextInput and only want to get the value when the user presses "enter".
I would expect to listen to the onChange event. Unexpectedly, onChange fires on every key press. I figured out that React goes against web standards here. 🤦♂️
I then looked into the source code for the TextInput and noticed that there’s a onEnterPressed callback prop that I can use. It works, but the return value is inconsistent with the onChange callback prop.
onChange: returns value
onEnterPressed: returns SyntheticBaseEvent
It would be nice if both callback props would behave similar. :)
Usage right now:
onChange={(value) => {
// → value
}}
onEnterPressed={(event) => {
// → event.target.value
}}
@getflourish @jonasbuechel I have made a PR for this and it is approved, but it is a breaking change so wanted to get your feedback before I merged. At your connivence. Thanks!
Quite stale issue
Newest component doesn't have onEnterPressed so I will close the issue