Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoFocus property doesn't work #28

Closed
wookiem opened this issue Jun 25, 2017 · 1 comment
Closed

autoFocus property doesn't work #28

wookiem opened this issue Jun 25, 2017 · 1 comment

Comments

@wookiem
Copy link

wookiem commented Jun 25, 2017

NumberInput seems to disregard "autoFocus" prop. I was previously using refs to manage focus, but ran into issues when I started using react-dnd (drag and drop). Also, using refs is frowned upon in React.

Any chance that you can add autoFocus support?

@wookiem
Copy link
Author

wookiem commented Jun 26, 2017

After further research, I realize now that this is not a react-number-input issue, but rather a React issue. I confirmed that react-number-input does in fact pass-through autoFocus to input as desired.

However, React doesn't act on autoFocus as one would hope. Further, it appears that you need to use refs for selecting/focusing among multiple input fields:
facebook/react#5534

In case anyone else is looking for a possible solution to using refs to select inputs with react-dnd, read on...

I didn't attempt the possible workaround described in react-dnd:
react-dnd/react-dnd#378

Instead, I was able to modify my use of refs such that they were only created and accessed within the children/grandchildren/etc. (or parent/grandparent/etc.) of ConnectDragSource or ConnectDragTarget-wrapped components. Just stay away from creating or using refs within the wrapped component itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant