Carbon: Support forward ref for TextInput.PasswordInput component

Created on 20 Apr 2020  路  4Comments  路  Source: carbon-design-system/carbon

Summary

I鈥檓 able to set focus for a normal TextInput component, but not for a TextInput.PasswordInput component.

Test code:

// this works
<TextInput
  ref={input => input && input.focus && input.focus()}
  type="text"
  labelText="Username"
  ...
/>

// this doesn't work
<TextInput.PasswordInput
  ref={input => input && input.focus && input.focus()}
  labelText="Password"
  ...
/>

The ref for TextInput.PasswordInput isn鈥檛 working as I see this warning:

Warning: Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?

Justification

A PasswordInput should have the same functionality as a TextInput.

text-input react dev 馃 help wanted 馃憪 enhancement 馃挕

All 4 comments

@emyarod I checked this and found the ref forwarding is not applied to PasswordInput function. Are you working on this? If not I am very much interested in working on this.

@code-blooded-developer thanks, I was going to take a look near the end of the day but you can go ahead and open a PR

Thanks for fixing this! Is there a release date planned for this?

@queeniema should be available in the next patch release (usually about a week between them)

Was this page helpful?
0 / 5 - 0 ratings