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.

Unable to cleanly disable keyboard in iOS in TextInput (Continuing from #14045)

See original GitHub issue

I read the full discussion in #14045 and it seems to have been auto-closed without sufficient resolution. It would be great if we could have sufficient resolution of this issue without it being prematurely closed.

The issue here is that there is no way to disable the keyboard from popping up on a text input field while still allowing the user to paste into the field, which works for both iOS and Android.

  • If you set editable={false} then you can’t paste into it so that doesn’t work as a solution.
  • Using onFocus={() => Keyboard.dismiss()} is not acceptable because the keyboard pops up for a second (both iOS and Android) so this can’t be used.
  • Using the new prop showSoftInputOnFocus does exactly what is wanted but it only works for Android. (Side note: it seems this prop isn’t included in the latest typings in 0.61.4, so there is a typescript error even though the prop works)

How can we make this work sufficiently for both iOS and Android?

React Native version: System: OS: Linux 4.15 Ubuntu 18.04.3 LTS (Bionic Beaver) CPU: (8) x64 Intel® Core™ i7-9700K CPU @ 3.60GHz Memory: 3.75 GB / 61.90 GB Shell: 5.4.2 - /bin/zsh Binaries: Node: 12.13.0 - /usr/bin/node Yarn: 1.19.1 - /usr/bin/yarn npm: 6.12.0 - /usr/bin/npm SDKs: Android SDK: API Levels: 23, 26, 28, 29 Build Tools: 23.0.1, 25.0.0, 28.0.3, 29.0.0, 29.0.2 System Images: android-28 | Google APIs Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom_64 npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.4 => 0.61.4 npmGlobalPackages: react-native-cli: 2.0.1 react-native: 0.61.2

Steps To Reproduce

  1. Add a <TextInput /> component
  2. Try to hide the keyboard from showing while still maintaining the ability to paste into it.

Describe what you expected to happen: There should be some way we can make iOS and Android behave the same for this.

Sample code:

<TextInput
  onFocus={() => Keyboard.dismiss()}
  autoFocus={true}
  showSoftInputOnFocus={false}
  placeholder={"Some sample text"}
/>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:26
  • Comments:18 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
MrLohcommented, Feb 14, 2020

@stale fuck off stale bot. No one ever looked at this, but otherwise nothing is stale about this

6reactions
criticalmiindcommented, Jan 9, 2021

try this solution i hope this will work for android and ios both…

        // Step 1: Get Keyboard, TouchableWithoutFeedback from ‘react-native’;
        import { View, TextInput, StyleSheet, Keyboard,  TouchableWithoutFeedback } from 'react-native';

        // Step 2: Create an arrow function to write dismiss keyboard code
        const DismissKeyboard = ({ children }) => (
            <TouchableWithoutFeedback onPress={() => Keyboard.dismiss()}>
                {children}
            </TouchableWithoutFeedback>
            );

        // Step 3: Wrap all TextInput inside <DismissKeyboard> </DismissKeyboard>
        //Example
        <DismissKeyboard>
            <View style={styles.container}>
                <TextInput style={styles.input} placeholder="email" />
                <TextInput style={styles.input} placeholder="password" />
            </View>
        </DismissKeyboard>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Disable Keyboard Shortcut Bar | Apple Developer Forums
Is it possible to disable the keyboard shortcut bar in iOS9? ... need to set both Predictive and Shortcuts off on iPad to...
Read more >
How to disable keyboard in react native
Step 1: Get Keyboard, TouchableWithoutFeedback from 'react-native'; import { View, TextInput, StyleSheet, Keyboard, TouchableWithoutFeedback } ...
Read more >
Department of Information Resources
4.4.2 HUB Continuing Performance. Any contracts awarded as a result of this RFO shall include reporting responsibilities related to HUB subcontracting.
Read more >
1 2 3 4 5 6 7 8 9 A
NC Start disable in this channel. Interface signals are set. Alarm display. NC alarms. 4.1 NC alarms. Alarms. Diagnostics Manual, 07/2022, A5E47438220B AF....
Read more >
TextInput
This may cause issues with components that have position: 'absolute' while the keyboard is active. To avoid this behavior either specify ...
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