satya164 / react-native-tab-view

A cross-platform Tab View component for React Native
MIT License
5.14k stars 1.07k forks source link

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

Open PeterFred opened 3 years ago

PeterFred commented 3 years ago

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

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
Adam-Schlichtmann commented 2 years ago

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 commented 2 years ago

Opened a PR at https://github.com/callstack/react-native-pager-view/pull/567 to fix this.

See https://github.com/callstack/react-native-pager-view/issues/566 for more context.

Stefanats commented 2 years ago

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

jeyjeycodes commented 2 years ago

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

jeyjeycodes commented 2 years ago

@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