react-native-bottom-sheet icon indicating copy to clipboard operation
react-native-bottom-sheet copied to clipboard

[v4] BottomSheetTextInput can't open keyboard in android

Open qaws5503 opened this issue 2 years ago • 2 comments

Bug

When using BottomSheetTextInput, it works fine on iOS. But when using in android, it will open the keyboard and stretch the bottomSheet as expected. And after keyboard is fully displayed it will dismiss instantly, which is not right.

After some test, I found out it is the problem with style flex. When I don't set flex in styles.container it works fine, but add flex:1 it automatically dismiss keyboard when keyboard is fully displayed.

Not sure if this is an issue with android:windowSoftInputMode, since I'm using Expo and I didn't set softwareKeyboardLayoutMode. So it's the default value: resize which mentioned here.

Environment info

Library Version
@gorhom/bottom-sheet 4.1.5
react-native 0.68.2
react-native-reanimated 2.8.0
react-native-gesture-handler 2.2.1
expo sdk 45

Steps To Reproduce

Example code from BottomSheetTextInput document here.

https://user-images.githubusercontent.com/57092368/188586875-1247316e-fcbb-49ae-9692-62b9e28cf5ca.mp4

Reproducible sample code

import React, { useCallback, useMemo, useRef } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import BottomSheet from '@gorhom/bottom-sheet';

const App = () => {
  // ref
  const bottomSheetRef = useRef<BottomSheet>(null);

  // variables
  const snapPoints = useMemo(() => ['25%', '50%'], []);

  // callbacks
  const handleSheetChanges = useCallback((index: number) => {
    console.log('handleSheetChanges', index);
  }, []);

  // renders
  return (
    <View style={styles.container}>
      <BottomSheet
        ref={bottomSheetRef}
        index={1}
        snapPoints={snapPoints}
        onChange={handleSheetChanges}
      >
        <View style={styles.contentContainer}>
          <Text>Awesome 🎉</Text>
        </View>
      </BottomSheet>
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    padding: 24,
    backgroundColor: 'grey',
  },
  contentContainer: {
    flex: 1,
    alignItems: 'center',
  },
});

export default App;

qaws5503 avatar Sep 05 '22 08:09 qaws5503

@qaws5503: hello! :wave:

This issue is being automatically closed because it does not follow the issue template.

github-actions[bot] avatar Sep 05 '22 08:09 github-actions[bot]

I confirm this is happening also on a Google Pixel 3XL and 4A device

gabimoncha avatar Sep 08 '22 12:09 gabimoncha

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

github-actions[bot] avatar Oct 09 '22 09:10 github-actions[bot]

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

github-actions[bot] avatar Oct 14 '22 09:10 github-actions[bot]

having this issue. any update

farhanhaider1 avatar Dec 29 '22 21:12 farhanhaider1

Same here

NathanPo avatar Jan 10 '23 23:01 NathanPo

Same here. Any ideas?

gediminastub avatar Aug 18 '23 10:08 gediminastub

Same

ChronoByteCosmonaut avatar Oct 19 '23 12:10 ChronoByteCosmonaut

Same

hugoPinho012 avatar Nov 13 '23 22:11 hugoPinho012

Same

kocaagasefa avatar Nov 14 '23 20:11 kocaagasefa

Issue happens when a user use an higher keyboard like Microsoft Swiftkey on an android device.

I use bottom-sheet inside a portal (gorhom/portal) and flex:1 solution did not solve my issue.

Using TextInput from react-native instead of BottomSheetTextInput solves the issue but then you lose some benefits that come from BottomSheetTextInput like expanding bottom sheet when input focused and closing keyboard when gesture down etc.

I hope this issue will be fixed on version 5.

hakanolgun avatar Nov 20 '23 13:11 hakanolgun