Keyboard doesn't show up when use someRef.current.focus()
See original GitHub issueHey! When use
someRef.current.focus()
nothing happends but if use
setTimeout(() => someRef.current.focus(), 0)
I don’t think that this a good idea It is a bug?
{
"dependencies": {
"@react-native-community/masked-view": "^0.1.9",
"@react-navigation/native": "^5.1.5",
"@react-navigation/stack": "^5.2.10",
"@types/react-navigation": "^3.4.0",
"react": "16.11.0",
"react-native": "0.62.2",
"react-native-screens": "^2.4.0",
},
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:21 (9 by maintainers)
Top Results From Across the Web
reactjs - Keyboard doesn't appears every focus - Stack Overflow
fieldOne.current.focus() it returnes me the following error : Cannot read ... Or maybe ref doesn't works good on react native paper element.
Read more >Focus on the Next TextInput when Next Keyboard Button is ...
The first step is getting a ref to our Last Name input. The one we want to focus on after our first input...
Read more >Initializing focus state in React: you might be doing it wrong
Initializing focus state in React: you might be doing it wrong. Have you ever written a component with internal state like hasFocus or...
Read more >TextInput - React Native
This may cause issues with components that have position: 'absolute' while the keyboard is active. To avoid this behavior either specify ...
Read more >Improve Accessibility in Your React App By Managing Focus ...
This means its not focusable through sequential keyboard navigation, but it can still be programatically focused to be set as the document.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Also noticing the same issue with RN 0.64.1.
The above hack
setTimeout(() => someRef.current.focus(), 0)
seems to work.This should be fixed in react-native 0.63 (currently in RC). See https://github.com/facebook/react-native/commit/6adba409e6256fd2dcc27a4272edcedae89927af, https://github.com/facebook/react-native/commit/055a41b081c5bc9535b071d9b4b7488b92e71803
Edit: In this case you’d need to use the autoFocus prop on TextInput instead of focusing from JS with a ref.