amplify-ui icon indicating copy to clipboard operation
amplify-ui copied to clipboard

onChange event for TextField component is wrong type

Open dreamorosi opened this issue 3 years ago • 4 comments

This issue is related to the amplify-ui@next for React.

The event passed as argument to the function should be something like ChangeEvent<HTMLInputElement>, like it is in <PasswordField>, but instead has any (see screenshot below). image

This means that when trying to access things like the value of the target (e.target.value) TS won't compile unless I explicitly set the type in the signature of the event handler like:

onChange={(e: ChangeEvent<HTMLInputElement>) => { /*...*/ }}

Expected: image

dreamorosi avatar Nov 14 '21 12:11 dreamorosi

good catch! TextField is a tricky component, as it can act as an input or a textarea depending on the value of the isMultiline property. Will take a look and provide a fix to provide type-safety on event handlers.

hvergara avatar Nov 15 '21 17:11 hvergara

@reesscot is working on splitting out TextArea and TextField. So this wrong type thing will be fixed by then

zchenwei avatar Feb 18 '22 18:02 zchenwei

This will be fixed in our next major release.

reesscot avatar Mar 17 '22 20:03 reesscot

This should be fixed @dreamorosi ! Please reopen if you are still having an issue.

ErikCH avatar Jul 29 '22 18:07 ErikCH

This should be fixed by 4.x release now

zchenwei avatar Nov 30 '22 18:11 zchenwei