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.

[iOS 13] TextInput with autoFocus often make cursor not movable

See original GitHub issue

React Native version:

System:
    OS: macOS Mojave 10.14.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
    Memory: 1.42 GB / 40.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.11.1 - /usr/local/bin/node
    Yarn: 1.19.0 - /usr/local/bin/yarn
    npm: 6.11.3 - /usr/local/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.2 => 0.61.2
  npmGlobalPackages:
    react-native-cli: 2.0.1

Steps To Reproduce

<TextInput
  ref={c => (this.acTextInput = c)}
  style={{ flex: 1, paddingVertical: 6, paddingLeft: 0, fontSize: 18 }}
  returnKeyType="search"
  enablesReturnKeyAutomatically
  autoCapitalize="none"
  autoCorrect={false}
  autoFocus // can't move cursor bug on iOS 13?
  placeholder={`Search`}
  placeholderTextColor="#646464"
  value="Some long string to reproduce tapping somewhere in this line"
/>
  1. Tap on text box, in middle or beginning. Often the cursor will then get “stuck” at beginning of TextInput’s. Tapping at end or moving cursor by dragging it (new gesture in iOS 13) would not move it anywhere, cursor snaps back to beginning of TextInput
  2. Defocus from TextInput then focus on it again, by user tap or this.acTextInput.focus() after render, would fix it. Tapping anywhere in TextInput would consistently place cursor where wanted.

Describe what you expected to happen:

Step 2 above

My workaround is don’t use autoFocus, and have this on TextInput shown (inside a normally hidden modal):

    setTimeout(() => {
      this.acTextInput?.focus()
    }, 100)

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:13
  • Comments:12

github_iconTop GitHub Comments

3reactions
barrylachapellecommented, Dec 17, 2019

This was a breaking change in iOS 13 that Apple made - it hit me hard in a Swift/Xcode project. It has to do with moving the focus/becomeFirstResponder from viewWillAppear to viewDidLoad in the appropriate view controller. I imagine this is something deep in React Native that will have to be fixed.

The above timeout hack worked for me…nice idea!

2reactions
jamesxabregascommented, Oct 20, 2020

I’ve come across this issue too. I notice that it is no longer an issue in iOS 14, but remains in iOS 13 even when running the latest React Native version (0.63.3).

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't move the cursor around anymore - Apple Community
tap and hold the spacebar. You'll see all the key labels disappear and the cursor will start to float. You can then drag...
Read more >
React Native: How to select the next TextInput after pressing ...
Set the second TextInput focus, when the previous TextInput 's onSubmitEditing is triggered. Try this. Adding a Ref to second TextInput
Read more >
Text Input Cursor Automatically Placed? (Sugarcube) - Twine
Yes. There's no automatic way to do that currently, however, so it'll require a little setup to achieve. Preface: In SugarCube, the ...
Read more >
Focusing: focus/blur - The Modern JavaScript Tutorial
Modern HTML allows us to do many validations using input attributes: required , pattern and so on. And sometimes they are just what...
Read more >
Handling common accessibility problems - MDN Web Docs
Really, the aim of accessibility is to make your websites/apps ... 100% success or not; 100% accessibility is pretty much impossible to ...
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