Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

returnKeyType="next" doesn't move to next TextInput anymore #25721

Closed
Nantris opened this issue Jul 18, 2019 · 21 comments
Closed

returnKeyType="next" doesn't move to next TextInput anymore #25721

Nantris opened this issue Jul 18, 2019 · 21 comments
Labels
Bug Component: TextInput Related to the TextInput component. Resolution: Locked This issue was locked by the bot.

Comments

@Nantris
Copy link

Nantris commented Jul 18, 2019

React Native Version: 0.59.8 (Expo)

React Native version:
  React Native Environment Info:
    System:
      OS: Windows 7
      CPU: (2) x64 Intel(R) Core(TM) i5-4690K CPU @ 3.50GHz
      Memory: 4.53 GB / 13.75 GB
    Binaries:
      Yarn: 1.15.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.2.0 - C:\Users\User\AppData\Roaming\npm\npm.CMD
    IDEs:
      Android Studio: Version  2.3.0.0 AI-162.3871768

Physical device, Pixel 2, running Android 9. Using Google's GBoard.

Steps To Reproduce

  1. Run this Expo Snack: https://snack.expo.io/S1XcHwA-H
  2. Select the first TextInput
  3. Press the returnKey

Describe what you expected to happen:

Previously I had no problem with returnKeyType="next" moving to the next text field

Snack, code example, or link to a repository:

https://snack.expo.io/S1XcHwA-H (Same as above)

@Nantris Nantris added the Bug label Jul 18, 2019
@react-native-bot react-native-bot added the Component: TextInput Related to the TextInput component. label Jul 18, 2019
@kiranjd
Copy link

kiranjd commented Jul 19, 2019

If you want to focus on the next text input, first you have to get ref of that TextInput component like this,

          ref={ref => {
            this.secondInput = ref;
          }}

Specifying returnKeyType will only change which icon will be displayed on the keyboard. To incorporate functionality you have to know when the user has submitted using onSubmitEditing.

onSubmitEditing={() => this.secondInput.focus()}

When user presses the return key it will focus on the ref you have provided i.e., secondInput.

You can refer to this snack for working example

@Nantris
Copy link
Author

Nantris commented Jul 20, 2019

Weird. What I was doing worked perfectly for me 2 months ago before I upgraded Expo (from version 31, React Native 0.57). I only used onSubmitEditing on my final field on each screen to handle submission. I tested it and was happy with how it worked.

Am I crazy? The keyboard would stay up and the next field would be focused when I hit the return key, without any use of refs or onSubmitEditing

@stale
Copy link

stale bot commented Oct 18, 2019

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Oct 18, 2019
@stale
Copy link

stale bot commented Oct 25, 2019

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Oct 25, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Oct 26, 2019
@elicwhite elicwhite reopened this Nov 5, 2019
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Nov 5, 2019
@facebook facebook unlocked this conversation Nov 5, 2019
@elicwhite
Copy link
Member

I'm reopening this because I think this is a real problem that would be great to nail down. I'd really appreciate any sort of granular bisect that showed what version this bug was introduced in.

@Nantris
Copy link
Author

Nantris commented Nov 5, 2019

This is welcome news. I was doubting my sanity a little bit over this issue back in July.

@elicwhite
Copy link
Member

I tried creating a project with 0.57.8 (based on your comment in July). It doesn't seem to work on that version either.

npx react-native-cli init textinputnext057 --version 0.57.8
cd textinputnext057/
npx react-native-cli run-android
npx react-native-cli start

With App.js of:

import React, {Component} from 'react';
import {Platform, StyleSheet, Text, TextInput, View} from 'react-native';

type Props = {};
export default class App extends Component<Props> {
  render() {
    return (
      <View style={styles.container}>
        <TextInput placeholderTextColor="#666" placeholder="First" style={styles.input} returnKeyType="next" />
        <TextInput placeholderTextColor="#666" placeholder="Second" style={styles.input} returnKeyType="next" />
        <TextInput placeholderTextColor="#666" placeholder="Third" style={styles.input} returnKeyType="next" />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',
    padding: 8,
  },
  input: {
    padding: 20,
    margin: 20,
    backgroundColor: 'rgba(255,100,100,.5)'
  }
});

@elicwhite
Copy link
Member

0.55.4 seems to have the same problem. Clicking next closes the keyboard and doesn't focus the next input.

npx react-native-cli init textinputnext055 --version 0.55.4
cd textinputnext055/
npx react-native-cli run-android
npx react-native-cli start

@elicwhite
Copy link
Member

I believe this functionality was added in this commit dd8caf4 which first went out in 0.27.

I was able to get a project set up on 0.27.2 (which I'm shocked I was able to get working) and it shows the next button, but has the same problem. Are we sure this has ever worked?

If you could find a repro of this working at some point, that would be pretty helpful. :D

@Nantris
Copy link
Author

Nantris commented Nov 5, 2019

Unfortunately I don't have a repo to show. I also can't be 100% sure this ever worked in plain React-Native since I've always used Expo. I'm 99.9% sure this was working in the past with Expo though. I'd have no doubt at all except for all the evidence that this supposedly never worked.

After being assured that nothing changed on Expo's end I opened this issue figuring the issue must be somewhere deeper

It's possible that this previously worked as a result of something Expo was doing, but I didn't think it seemed likely that they'd touch that sort of very niche logic.

My specific recollection is that I was able to use the return key to move to the next input on my login/signup form of 2-3 inputs and being happy with the functionality. Back then my app was in such rough shape that inputs would often end up behind the keyboard, and I remember using the return key to move to those fields behind the keyboard. I wonder if some mix of Android version and React-Native version could have any bearing?

I truly believe this used to work, but substantial evidence seems to indicate that it did not. Perhaps this is a failure of human memory, but I'm having a hard time accepting it if that's the case, but it can't be ruled out.

@elicwhite
Copy link
Member

elicwhite commented Nov 6, 2019

Thanks for the follow up!

So the return key has the correct behavior but not next? That might be a good point for us to investigate.

Regardless, it seems like this should work, just that a bisect won't help us figure out how to fix it. I think we are trying to find someone from our side to work on this.

@Nantris
Copy link
Author

Nantris commented Nov 6, 2019

@TheSavior thanks to you for taking a look at this. Can you clarify this question if my response doesn't answer your question?

So the return key has the correct behavior but not next? That might be a good point for us to investigate.

If we define correct behavior as both displaying the next icon on the return key and moving to the next input upon pressing it, no. The icon shows, but pressing it does not move to the next input. My recollection is that the icon and the behavior worked with Expo 31 though.

@elicwhite
Copy link
Member

elicwhite commented Nov 6, 2019

Heh, I can see how that was confusing. Does the done key go to the next input or just close the keyboard?

@Nantris
Copy link
Author

Nantris commented Nov 7, 2019

Just closes the keyboard (and that's what it used to do as well.)

@LuizFBrisighello
Copy link

Any updates?

@stale
Copy link

stale bot commented Apr 30, 2020

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.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 30, 2020
@Nantris
Copy link
Author

Nantris commented Apr 30, 2020

@TheSavior I assume this behavior was either introduced by something other than React Native, or I crossed into a parallel universe at some point.

With that in mind, I guess this isn't a bug - but it would be a welcome feature request. Is there any appetite for this as a feature request? It would be majorly helpful for the developer experience if there was some sort of default action like users would get in a traditional DOM.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 30, 2020
@elicwhite
Copy link
Member

Yeah, my guess is that this only changed the key type, but still required being wired up to go to the next input manually.

I don't know of a way to implement this generically without fixing a core issue. I think having something like web / desktop's tab support to go through focusable elements is needed and would naturally plug in here, but that is a bigger scope feature that we'll need to prioritize down the line.

As for this issue, I'm not sure there is anything actionable here now. This unfortunately needs to be wired up manually for individual apps

@Nantris
Copy link
Author

Nantris commented Apr 30, 2020

Thanks a lot for the response @TheSavior. Looking forward to a future version where this is handled automatically, but until then, agreed - nothing actionable here. Thanks again!

@Nantris Nantris closed this as completed Apr 30, 2020
@devhyunjae
Copy link

Any updates here? I also remember next was working without ref , but now it doesn't...sad

@nhutruong99
Copy link

I tried the ios version of this function, returnKeyType, works on the android platform for some reason. It does still displayed an error that android doesn't support but it works LOL

@facebook facebook locked as resolved and limited conversation to collaborators Oct 7, 2021
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: TextInput Related to the TextInput component. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

7 participants