Skip to content
This repository has been archived by the owner on Nov 27, 2022. It is now read-only.

[V3] [iOS] TextInput dismisses keyboard automatically on focus #1244

Open
1 of 5 tasks
PeterFred opened this issue Aug 15, 2021 · 55 comments
Open
1 of 5 tasks

[V3] [iOS] TextInput dismisses keyboard automatically on focus #1244

PeterFred opened this issue Aug 15, 2021 · 55 comments

Comments

@PeterFred
Copy link

Current behavior

KeyboardNotShowing

After upgrading from v2.15.2 -> x3.1.1
TextInput box in iOS automatically dismisses the keyboard when focused. (Clicking in the TextInput box shows the keyboard only momentarily, before being automatically dismissed)

Works fine in Android, and previous version.

I created a quick snack, but does not seem to be an issue there. (Perhaps as this is a native project and snack uses expo)

Code to reproduce:

import {TextInput, useWindowDimensions, View} from 'react-native';
import {SceneMap, TabView} from 'react-native-tab-view';

const ListScreen = () => {
  const [text, onChangeText] = useState('Input Box text');

  const FirstRoute = () => (
    <View style={{flex: 1, backgroundColor: '#ff4081'}}>
      <TextInput
        style={{
          margin: 12,
          borderWidth: 1,
          padding: 10,
        }}
        onChangeText={onChangeText}
        value={text}
      />
    </View>
  );

  const SecondRoute = () => (
    <View style={{flex: 1, backgroundColor: '#673ab7'}} />
  );

  const renderScene = SceneMap({
    first: FirstRoute,
    second: SecondRoute,
  });

  const [index, setIndex] = React.useState(0);
  const [routes] = React.useState([
    {key: 'first', title: 'First'},
    {key: 'second', title: 'Second'},
  ]);

  const layout = useWindowDimensions();

  return (
    <TabView
      navigationState={{index, routes}}
      renderScene={renderScene}
      onIndexChange={setIndex}
      initialLayout={{width: layout.width}}
    />
  );
};

export default ListScreen;

Expected behavior

Keyboard should display when using a TextInput

Reproduction

https://snack.expo.dev/AVquvlCsS

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Environment

package version
react-native-tab-view 3.1.1
react-native-pager-view 5.4.0
react-native 0.64.2
expo N/A
node 16.3.0
npm or yarn yarn
@github-actions
Copy link

Couldn't find version numbers for the following packages in the issue:

  • expo

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

@PeterFred
Copy link
Author

Not using expo, vanilla react-native project

@sufyan297
Copy link

Same issue happening with me, working fine for Android

@PeterFred
Copy link
Author

First noticed with react-native-paper Searchbar, but narrowed it down to this issue

@achuinard
Copy link

It looks like the tab-view is re-calling renderScene when the TextInput is clicked. I have no idea why. This is a killer for me too.

@achuinard
Copy link

This might be related - callstack/react-native-pager-view#382

@HuyCNTT97
Copy link

Hi, i have same issue, have anyone solved the problem? is the problem from the native-tab-view?

@achuinard
Copy link

achuinard commented Aug 27, 2021 via email

@HuyCNTT97
Copy link

HuyCNTT97 commented Aug 27, 2021

Don’t wrap your whole pager in a KeyboardAvoidingView.

On Fri, Aug 27, 2021 at 9:54 AM HuyCNTT97 @.***> wrote: Hi, i have same issue, have anyone solved the problem? is the problem from the native-tab-view? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1244 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSVDYZBNM5KIRHVLRGQFLT66KJXANCNFSM5CGVPTWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Thanks for your reply. I don't use paperview, i create one Scene following code:
<View>
<Input >
</Input>
</View>

@HuyCNTT97
Copy link

HuyCNTT97 commented Aug 29, 2021

Hi, Any solutions please? it works fine in Android

@PeterFred
Copy link
Author

Not as yet, removing KeyboardAvoidingView from our app also did not resolve this.
As this package upgrade is a dependency for the upgrade to RN Navigation v6 it is holding up our upgrade for Nav.
https://reactnavigation.org/docs/upgrading-from-5.x/#minimum-requirements

@GaylordP
Copy link

GaylordP commented Sep 3, 2021

Hello,

I have the same very, very annoying problem : react-navigation/react-navigation#9902

Have you solved the problem @PeterFred ?

@GaylordP
Copy link

GaylordP commented Sep 3, 2021

In addition, I think that it is the use of two components simultaneously that is problematic, even with basic examples :

In the first example I am using react-navigation/material-top-tabs AND react-navigation/material-bottom-tabs.
In the second, I only use react-navigation/material-top-tabs
In the third, I only use react-navigation/material-bottom-tabs

@PeterFred
Copy link
Author

@GaylordP unfortunately not, we have delayed upgrading this package and navigation for now.

@iqbalhusen
Copy link

Facing same issue. Any temporary workaround?

@iqbalhusen
Copy link

iqbalhusen commented Sep 5, 2021

A very ugly temporary workaround:

let t;

const Component = () => {
  const textInputRef = useRef();

  return (
    <TextInput
      value={'test'}
      ref={textInputRef}
      onFocus={() => {
        t = +new Date(); // get unix-timestamp in milliseconds
      }}
      onBlur={() => {
        if (+new Date() - t < 500) {
          textInputRef.current.focus();
        }
      }}
    />
  );
};

@sangolariel
Copy link

sangolariel commented Sep 13, 2021

same issue anyone resolved?

@matthieunelmes
Copy link

Same problem here, the only way I could solve it was to downgrade to 2.16.0

@TfADrama
Copy link

I have the same problem on version 4.2.0, but not in another project that uses the same version... weird.

@satya164
Copy link
Owner

satya164 commented Oct 1, 2021

@PeterFred
Copy link
Author

PeterFred commented Oct 12, 2021

@satya164
callstack/react-native-pager-view#382
callstack/react-native-pager-view#462
Have upgraded react-native-pager-view to 5.4.7 but still persists

@sangolariel
Copy link

Hi, It seems still an issue now. you need to downgrade to "react-native-tab-view": "^2.15.2". It will work but it is not the best solution. Hope the new release will resolve it.

@imranssuetian
Copy link

Don’t wrap your whole pager in a KeyboardAvoidingView.

On Fri, Aug 27, 2021 at 9:54 AM HuyCNTT97 @.***> wrote: Hi, i have same issue, have anyone solved the problem? is the problem from the native-tab-view? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1244 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADSVDYZBNM5KIRHVLRGQFLT66KJXANCNFSM5CGVPTWA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

Perfect answer

@divyesh-puri
Copy link

divyesh-puri commented Nov 9, 2021

@satya164 callstack/react-native-pager-view#382 callstack/react-native-pager-view#462 Have upgraded react-native-pager-view to 5.4.7 but still persists

@satya164 ping

@hungvu193
Copy link

any updates?

@willmorim
Copy link

same problem here :(

@Oguntoye
Copy link

Oguntoye commented Dec 14, 2021

This resolves the issue, there is also pending PR for it. But it adds padding after the keyboard appears. Downgrading to react-native-tab-view to v2.16.0 seems to be best option for now.

react-native-pager-view

Downgraded to 2.16.0..
The TextInput still loosing focus

@Off2Race
Copy link

Off2Race commented Jan 3, 2022

Hi, @gamingumar – I tried the react-native-pager-view change you referenced but it caused other issues with scene rendering when I switched tabs. The keyboard issue was gone (for me) but the side effects were unfortunately worse.

@zxymgl
Copy link

zxymgl commented Feb 28, 2022

Hi, i have same issue, have anyone solved the problem? is the problem from the native-tab-view?

@jawadkhan653
Copy link

same issue , anyone found this solution ?

@ig4ever
Copy link

ig4ever commented Mar 7, 2022

Hi, i have same issue, have anyone solved the problem? is the problem from the native-tab-view?

@zxymgl @jawadkhan653 i think the loop render cause these problems, i found the solution by adding React.memo inside the Tab Component to prevent the loop render

image

@CCB-cerivera
Copy link

Hi, i have same issue, have anyone solved the problem? is the problem from the native-tab-view?

@zxymgl @jawadkhan653 i think the loop render cause these problems, i found the solution by adding React.memo inside the Tab Component to prevent the loop render

image

Don´t working, other solution ?

@jawadkhan653
Copy link

Downgrading to react-native-tab-view to v2.16.0 worked for me !!!

@CCB-cerivera
Copy link

Downgrading to react-native-tab-view to v2.16.0 worked for me !!!

Downgrading to react-native-tab-view to v2.16.0 worked for me !!!

Correct, I tried the following versions and it doesn't work, only from version 2.16.0 backwards.

@rashonwill
Copy link

rashonwill commented Apr 13, 2022

Having this issue as well. Any other solutions? Downgrading did not resolve.

@Oguntoye
Copy link

@rashonwill and @CCB-cerivera .

You can try it as follow

  1. declare a const for the scenes
    const renderScene = ({ route }) => { switch (route.key) { case 'first': return ( <View> </View> ); case 'second': return ( <View> </View> ); default: return null; } }

  2. Inside your component return function

    <TabView navigationState={{ index, routes }} renderScene={renderScene} onIndexChange={setIndex} initialLayout={{ width: layout.width }} renderTabBar={props => ( <TabBar {...props} renderLabel={({ route, color }) => ( <Text> {route.title} </Text> )} style={{backgroundColor:'transparent'}} indicatorStyle = {{backgroundColor:PRIMARY}} /> )} />

@rashonwill
Copy link

rashonwill commented Apr 13, 2022

@Oguntoye unfortunately, that did not resolve things either.

@Oguntoye
Copy link

@Oguntoye unfortunately, that did not resolve things either.

Can you share your code snippet

@rashonwill
Copy link

rashonwill commented Apr 13, 2022

@Oguntoye unfortunately, that did not resolve things either.

Can you share your code snippet

const renderScene = ({route}) => {
switch (route.key) {
case 'synopsis' :
return ;
case 'comments':
return ;
case 'recommended':
return ;
default: return null;
}
}

const [index, setIndex] = React.useState(0);
const [routes] = React.useState([
{ key: 'synopsis', title: 'Synopsis' },
{ key: 'comments', title: 'Comments' },
{ key: 'recommended', title: 'Recommeded' },
]);

const renderTabBar = (props) => (
<TabBar
{...props}
indicatorStyle={{ backgroundColor: '#fdfbf9', color: '#fdfbf9' }}
style={{ backgroundColor: '#171717' }}
renderLabel={({ route, focused, color }) => (
<Text
style={{
color,
margin: 5,
fontSize: 15,
fontFamily: 'Teko_700Bold',
}}>
{route.title}

)}
/>
);

@rashonwill
Copy link

image

@rashonwill
Copy link

image
.

@Oguntoye
Copy link

@rashonwill .Instead of having your synopsis component in a different file.. define it inside
Avoid having the component in separate files

Like so
1.
Screen Shot 2022-04-13 at 8 53 23 PM

Screen Shot 2022-04-13 at 8 54 37 PM

  1. Inside your return render function
    Screen Shot 2022-04-13 at 8 55 01 PM

@rashonwill
Copy link

Oh the functions are all in the same js file, but trying to do it this way causes other errors with navigation route params, etc for me
image

@rashonwill
Copy link

rashonwill commented Apr 14, 2022

I was able to resolve the issue, by removing the Render Scenes to their own separate js
file and using React.memo to wrap the function upon export to avoid the re-rendering as per documentation.

https://github.com/satya164/react-native-tab-view

image
image

@jeyjeycodes
Copy link

PING!! I am having the exact same issue! Any progress

@Devenom1
Copy link

PING!! I am having the exact same issue! Any progress

@jeylanicodes Same here. Is it only on iOS 15.4 and 15.4.1?

@jeyjeycodes
Copy link

jeyjeycodes commented Apr 22, 2022

PING!! I am having the exact same issue! Any progress

@jeylanicodes Same here. Is it only on iOS 15.4 and 15.4.1?

@Devenom1. I am not to sure but putting it back to version 2.16.0 works but if you are using react-navigations and material-top-tabs V6 you will get type errors which is soooo annoying. The whole is built on V6 and downgrading the whole of react navigation to V5 is A HEADACHE!!

@rashonwill Could you give an example of your code. Because this does not work for me.

@CCB-cerivera and @jawadkhan653 how did you guys resolve the type issues if you had any!

THIS NEEDS TO BE PRIORITISED! Who can I contact to actually attempt to fix this at a High level urgency??

@jeyjeycodes
Copy link

jeyjeycodes commented Apr 22, 2022

I stand corrected. You MAY be able to just downgrade react-native-tab-view to 2.16.0 and react native navigation top tabs to V5

@CCB-cerivera
Copy link

@jeylanicodes

Hi!, I tried the following versions and it doesn't work, only from version 2.16.0 backwards it worked for me.

The issue is still open so the component developer has not fixed it.

I suppose that using the latest version of the component and the latest version of react and expo, maybe it will work, however, many like me do not have all the updates fully installed.

The only thing that works at the moment is to downgrade to version 2.16.0

@Adam-Schlichtmann
Copy link

I also have been experiencing this using with an App using Expo v44 and decided to downgrade to 2.16.0 as mentioned here.
When I downgraded remote debugging no longer was working so I went searching for another solution.

I am using @react-navigation/material-top-tabs inside of @react-navigation/material-bottom-tabs. I found that switching to @react-navigation/bottom-tabs fixed the issue for me.

Hope this helps someone else out.

@andreialecu
Copy link

Opened a PR at callstack/react-native-pager-view#567 to fix this.

See callstack/react-native-pager-view#566 for more context.

@Stefanats
Copy link

windowSoftInputMode="adjustPan"
instead of
windowSoftInputMode="adjustResize";
in your AndroidManifest.xml
worked for me!

@jeyjeycodes
Copy link

jeyjeycodes commented Jun 18, 2022

@andreialecu It looks like it is working after upgrading react-native-pager-view!! You are a legend!!!

@jeyjeycodes
Copy link

@achuinard it looks like this did fix it, however there is another issue now whereby a block appears at the bottom of the screen where the keyboard was

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests