material-bread icon indicating copy to clipboard operation
material-bread copied to clipboard

TextField focused prop display only?

Open maxstudener opened this issue 6 years ago • 5 comments

Describe the bug No possible way to apply focus to input. I suggest either maintaining a ref that gets passed to the TextInput or allowing users to pass their own ref into TextField.

To Reproduce Steps to reproduce the behavior: When clicking a button and changing the focused prop on a TextField from false to true, it is only displayed as focused but when I start typing the browser's focus and mobile focus is still on the button.

Expected behavior Focused prop actually focuses the input and using a ref.

maxstudener avatar Oct 09 '19 20:10 maxstudener

TextFieldFlat js — material-bread 2019-10-13 23-33-13

For refs, we are spreading the all additional props onto the TextInput element, that should allow for a custom ref.

I agree toggling focused should automatically call .focus()

Thanks!

codypearce avatar Oct 14 '19 06:10 codypearce

I just hit this too - I don't think refs get forwarded in the same way as other props, at least using something like:

<TextField
  ref={r => this.thing = r}
/>

in React Native gives the error thing.focus() is not a function. see https://reactjs.org/docs/forwarding-refs.html

bcgilliom avatar Dec 26 '19 19:12 bcgilliom

I also just hit this. Is there a workaround for this? I can't focus the second input using onSubmitEditing on the first to reference the second...

pinpointpanda avatar Jun 03 '20 18:06 pinpointpanda

I have just hit this too guys. I agree with @bcgilliom, they are not forwarded the same way as othe props.

Any eta on getting a fix for this?

allens01 avatar Jun 30 '20 08:06 allens01

I also have the "focus() is not a function" issue, can anyone help? I am very need it on my work.

tomcheung1208 avatar Oct 20 '20 02:10 tomcheung1208