question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keyboard doesn't show up when use someRef.current.focus()

See original GitHub issue

Hey! 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:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:21 (9 by maintainers)

github_iconTop GitHub Comments

12reactions
KatiRasanencommented, May 18, 2021

Also noticing the same issue with RN 0.64.1.

The above hack setTimeout(() => someRef.current.focus(), 0) seems to work.

3reactions
janicduplessiscommented, Apr 29, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found