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

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

Closed
farhann1 opened this issue Apr 18, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@farhann1
Copy link

farhann1 commented Apr 18, 2024

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 farhann1 added the bug Something isn't working label Apr 18, 2024
@jasimchz
Copy link

try this props

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

@farhann1
Copy link
Author

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.

@Lelouch65428
Copy link

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.

@Mitrandir-main
Copy link

Same issue, any other ideas?

@Lelouch65428
Copy link

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

@farhann1
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants