Skip to content

Keyboard dismiss not working after autocomplete #28025

Closed

Description

@mtourj

Description:

I am developing a React Native app using Expo and as I am building a login form, it seems that after autocompleting the form (on iOS), my calls to Keyboard.dismiss() do not work, and the keyboard stays where it is, which messes with my UI badly.

React Native version:

react: 16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-36.0.1.tar.gz => 0.61.4

Steps To Reproduce

Build a login form with two TextInputs:
One with keyboardType='email-address' and one with secureTextEntry. This will let iOS know that credentials can go here.

Add a button that simply calls Keyboard.dismiss()

Now in the app, focus on a TextInput, and use autocomplete to fill the fields (with data from whatever website/app)

Expected Results

Now, when you try to use your button to dismiss the keyboard, it wont go away. You would have to tap on another text field to get the keyboard to go away

Snack, code example, screenshot, or link to a repository:

          <TextInput
            placeholder='Email address'
            placeholderTextColor='rgba(44,44,44,0.4)'
            returnKeyType='next'
            onSubmitEditing={() => this.passwordInput.focus()}
            style={[
              styles.input,
              this.state.usernameError && styles.inputError
            ]}
            keyboardType='email-address'
            autoCapitalize='none'
            autoCorrect={false}
            onBlur={() => this.setState({ usernameError: '' })}
            value={this.state.username}
            onChangeText={text => this.setState({ username: text.trim() })}
          />
          <TextInput
            placeholder='Password'
            secureTextEntry
            returnKeyType='go'
            autoCapitalize='none'
            autoCorrect={false}
            onBlur={() => {
              Keyboard.dismiss();
              this.setState({ passwordError: '' });
            }}
            style={[
              styles.input,
              this.state.passwordError && styles.inputError
            ]}
            ref={input => (this.passwordInput = input)}
            value={this.state.password}
            onChangeText={text => this.setState({ password: text.trim() })}
          />
         <Button
               title="Dismiss Keyboard"
               onPress={Keyboard.dismiss}
           />

Activity

  1. someok commented on Apr 6, 2020

    @someok

    yes, I have save problem

  2. jaymdq commented on Apr 20, 2020

    @jaymdq

    Having the same problem over here
    react 16.9
    react-native 0.61.5

  3. musartedev commented on May 4, 2020

    @musartedev

    I have the same problem. I'm not using expo. It happens after Face Id autocompletion.
    react 16.9
    react-native 0.61.5

  4. rikur commented on May 21, 2020

    @rikur

    EDIT: I fixed my issue by useRef hook instead of a ref propertly like original poster.

  5. dann1609 commented on Jul 9, 2020

    @dann1609

    Same issue on same version. There is any solution or any version to migrate?

  6. stale commented on Oct 12, 2020

    @stale

    Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

  7. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Oct 12, 2020
  8. pdugan20 commented on Oct 12, 2020

    @pdugan20

    I'm no longer seeing this with the latest version of RN. Assuming it was fixed at some point?

  9. removed
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Oct 12, 2020
  10. verybluebot commented on Dec 23, 2020

    @verybluebot

    Still getting this

        "react": "16.11.0",
        "react-native": "0.62.2",
    
  11. bpofficial commented on Jul 16, 2021

    @bpofficial

    also still getting this

    "react": 16.13.1"",
    "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz"
    
  12. github-actions commented on Apr 6, 2023

    @github-actions

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  13. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Apr 6, 2023
  14. github-actions commented on Apr 13, 2023

    @github-actions

    This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Triage 🔍StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions