fondue icon indicating copy to clipboard operation
fondue copied to clipboard

TextInput: onEnterPressed & onChange behave differently

Open getflourish opened this issue 3 years ago • 1 comments

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 avatar Feb 16 '22 14:02 getflourish

@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!

ryancarville avatar Oct 25 '23 15:10 ryancarville

Quite stale issue Newest component doesn't have onEnterPressed so I will close the issue

SamuelAlev avatar Sep 03 '24 09:09 SamuelAlev