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

[v4] | Keyboard pushing bottom sheet content to screen top, with empty space in between

Open farhann1 opened this issue 10 months ago • 5 comments

Bug

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

<BottomSheetModalProvider>
  ....

  <BottomSheetModal
     ref={bottomSheetModalRef}
     index={0}
     snapPoints={snapPoints}
     onChange={handleSheetChanges}
     keyboardBlurBehavior='restore'
 >
           ....
                       </BottomSheetModal>
                  ....
               </BottomSheetModalProvider >


<BottomSheetTextInput style={{
       borderRadius: 10,
       borderWidth: 1,
       fontSize: 15,
       lineHeight: 15,
       padding: 12,
       marginVertical: 12
     }}
       keyboardType='numeric'
       placeholder="Enter amount as shown on bill"
       value={billAmount}
       onChangeText={
         amount => setBillAmount(amount.replace(TRAILING_ZEROS_REGEX, EMPTY_STRING))
       }
     />

Launching keyboard for BottomSheetTextInput, pushes the content to the top of the screen with empty space in between. This happens even though i am using the keyboardBehaviour as interactive.

Tried using android_keyboardInputMode also, but same issue.

With-Keyboard Without-Keyboard

Please note that issues that do not follow the template may be closed.

Environment info

Library Version
@gorhom/bottom-sheet 4.6.0
react-native 0.73.6
react-native-reanimated 3.6.2
react-native-gesture-handler 2.14.0

Steps To Reproduce

  1. Launch bottom sheet modal with bottom sheet text input.
  2. Use keyboardBehavior as interactive
  3. Observe the extra space between keyboard and content.

Describe what you expected to happen:

  1. Content should get pushed upwards by the height of the keyboard.

Reproducible sample code

WIP

farhann1 avatar Apr 18 '24 10:04 farhann1

try this props

keyboardBehavior={'interactive'}
keyboardBlurBehavior={'restore'}
<BottomSheetModal
              enableDynamicSizing
              keyboardBehavior={'interactive'}
              keyboardBlurBehavior={'restore'}
              {...rest}>
             ...
            </BottomSheetModal>

jasimchz avatar Apr 18 '24 14:04 jasimchz

enableDynamicSizing keyboardBehavior={'interactive'} keyboardBlurBehavior={'restore'}

Thanks for the suggestion @jasimchz , but i already tried out those props and it is not working for me..

Also when i add the enableDynamicSizing prop, the BottomSheetModal is not responding on button click anymore.

farhann1 avatar Apr 18 '24 14:04 farhann1

Try adding the provider on app.tsx. Also try removing snapPoints when enableDynamicSizing is true. To control the height you can add topInset accordingly else the modal will go to the max screen height.Try putting android_keyboardInputMode to adjustResize.

Lelouch65428 avatar Apr 18 '24 15:04 Lelouch65428

Same issue, any other ideas?

Mitrandir-main avatar Apr 23 '24 15:04 Mitrandir-main

@Mitrandir-main have you added the provider on app.tsx and put the modal outside your scrollview?

Lelouch65428 avatar Apr 25 '24 03:04 Lelouch65428

I replaced the BottomSheetTextInput with TextInput from 'react-native-paper' due to some styling reasons.. but surprisingly the above issue also got fixed with it. Cheer!

Resolving this issue for now.

farhann1 avatar May 10 '24 13:05 farhann1