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

[Bug]: keyboardBlurBehavior={'restore'} not working

Open florian-deroo opened this issue 4 months ago • 20 comments

Version

v5

Reanimated Version

v3

Gesture Handler Version

v2

Platforms

Android, iOS

What happened?

keyboardBlurBehavior={'restore'} isn't working, the position of the modal does not restore when i close the keyboard and there is a topInset

Reproduction steps

  • Open input
  • Close input

Reproduction sample

https://snack.expo.dev/@florianfrdev/bottom-sheet---issue-reproduction-template?platform=ios

Relevant log output


florian-deroo avatar Sep 09 '25 09:09 florian-deroo

<BottomSheetModal
    ref={bottomSheetModalRef}
    snapPoints={["60%", "100%"]}
    enableDynamicSizing={false}
    topInset={100}
    keyboardBlurBehavior={'restore'} 
>

actually adding "100%" to snapPoints helped in my case and your snack, yeah probably wont fit all the cases but could solve your issue temporarily.

your sample with the fix

doguyilmaz avatar Sep 09 '25 14:09 doguyilmaz

yes, same issue here with latest version

krishnan-456 avatar Sep 14 '25 05:09 krishnan-456

@gorhom

florian-deroo avatar Sep 16 '25 19:09 florian-deroo

does anyone find solution for this or do we have any hack to temporary fix this ?

krishnan-456 avatar Sep 19 '25 09:09 krishnan-456

The same issue

"expo": "~53.0.22",
"react-native": "0.79.5",
"@gorhom/bottom-sheet": "^5.2.6"

Akyna avatar Sep 21 '25 09:09 Akyna

this is happening only when enableDynamiceSize={true}

krishnan-456 avatar Sep 21 '25 15:09 krishnan-456

does anyone faced this issue with IOS ?

krishnan-456 avatar Sep 23 '25 08:09 krishnan-456

@krishnan-456 Yup, this is flawed on Android as well.

mefjuu avatar Sep 23 '25 10:09 mefjuu

We downgraded to the previous version (5.1.2) - works like a charm.

"expo": "~53.0.22",
"react-native": "0.79.5",
"@gorhom/bottom-sheet": "5.1.2"

Akyna avatar Sep 23 '25 11:09 Akyna

@Akyna can you share the reanimated version ? because it's throwing error.

Image

krishnan-456 avatar Sep 23 '25 15:09 krishnan-456

@Akyna can you share the reanimated version ? because it's throwing error.

"react-native-reanimated": "~3.17.5",

Akyna avatar Sep 24 '25 06:09 Akyna

We downgraded to the previous version (5.1.2) - works like a charm.

"expo": "~53.0.22",
"react-native": "0.79.5",
"@gorhom/bottom-sheet": "5.1.2"

yes, this fixed it for me as well!!

BoavistaLudwig avatar Sep 30 '25 10:09 BoavistaLudwig

<BottomSheetModal ref={bottomSheetModalRef} snapPoints={["60%", "100%"]} enableDynamicSizing={false} topInset={100} keyboardBlurBehavior={'restore'}

actually adding "100%" to snapPoints helped in my case and your snack, yeah probably wont fit all the cases but could solve your issue temporarily.

your sample with the fix

This worked for me without downgrading.

kvntzn avatar Oct 13 '25 06:10 kvntzn

does anyone faced this issue with IOS ?

Still having it

Mavludin avatar Oct 21 '25 19:10 Mavludin

I solved this issue by waiting for the keyboard to fully close.

My flow was this:

  1. BottomSheet with BottomSheetTextInput
  2. User types and sends a message - the BottomSheetTextInput blurs and a keyboard hide is triggered
  3. I wait for the keyboard to be fully closed
  4. Then send the message

The problem seemed to be that my send message code triggered a rerender of the component that holds my BottomSheet. Waiting for the keyboard to be fully closed ensures the restoring of the BottomSheet height.

Test by calling setTimeout(() => Keyboard.dismiss(), 500); explicitly and see if it restores.

Heres a hook I use that waits until the keyboard is closed for up to 450ms.

import { useCallback, useEffect, useState } from "react";
import { Keyboard, Platform } from "react-native";

/**
 * useKeyboard
 * Listens to keyboard show/hide events and exposes visibility state.
 * - iOS: listens to willShow/didShow and willHide/didHide for better responsiveness
 * - Android: listens to didShow/didHide
 * - Web: returns false (no-op)
 */
export const useKeyboard = () => {

  const waitForHide = useCallback((timeoutMs = 450) => {
    if (Platform.OS === "web") return Promise.resolve();
    return new Promise<void>((resolve) => {
      let done = false;
      const finish = () => {
        if (done) return;
        done = true;
        try {
          subWillHide?.remove();
        } catch {}
        try {
          subDidHide?.remove();
        } catch {}
        resolve();
      };

      const subWillHide = Platform.OS === "ios" ? Keyboard.addListener("keyboardWillHide" as any, finish) : null;
      const subDidHide = Keyboard.addListener("keyboardDidHide" as any, finish);

      setTimeout(finish, timeoutMs);
    });
  }, []);

  // Dismiss the keyboard and resolve once it's hidden (or timeout).
  const dismissSync = useCallback(
    async (timeoutMs = 450) => {
      Keyboard.dismiss();
      await waitForHide(timeoutMs);
    },
    [waitForHide]
  );

  return { isVisible, waitForHide, dismissSync };
};

FabianUntermoser avatar Oct 23 '25 08:10 FabianUntermoser

Something weird happen , i have the same issue , but if i do :

          ref={bottomSheetRef}
          title={t('modal.incomplete_address.edit.title')}
          snapPoints={['30%', '60%']}
          enableDynamicSizing={false}
          keyboardBlurBehavior={'restore'}

working fine ✅ , but the modal is showing too height

https://github.com/user-attachments/assets/26e02de4-c688-4071-a594-ac0395906d69

so i wanted to lower the snapPoints this is working fine


        <BottomSheetV2
          ref={bottomSheetRef}
          title={t('modal.incomplete_address.edit.title')}
          snapPoints={['56%']}
          enableDynamicSizing={false}
          keyboardBlurBehavior={'restore'}
        >

this is NOT working ( lower than 55% ) don't know why


       <BottomSheetV2
         ref={bottomSheetRef}
         title={t('modal.incomplete_address.edit.title')}
         snapPoints={['55%']} 👈👈
         enableDynamicSizing={false}
         keyboardBlurBehavior={'restore'}
       >

https://github.com/user-attachments/assets/00bdd4cd-0793-4f27-bb47-4067fc2b232e

even if i remove all this props ( commented code ) :

      <BottomSheet
        ref={ref}
        index={-1}
        // enableDynamicSizing
        // enablePanDownToClose={dismissible}
        // keyboardBehavior="interactive"
        // keyboardBlurBehavior="restore"
        // maxDynamicContentSize={Dimensions.get('window').height - 100}
        // enableBlurKeyboardOnGesture
        // topInset={100}
        {...props}

i don't get the expected behavior

SSylvain1989 avatar Oct 28 '25 14:10 SSylvain1989

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 Nov 28 '25 09:11 github-actions[bot]

Any updates?

Akyna avatar Nov 28 '25 09:11 Akyna

👀 is lib still maintained?

Fortidude avatar Dec 02 '25 18:12 Fortidude

This fix solves the problem https://github.com/gorhom/react-native-bottom-sheet/pull/2511

Just patch it.

Mavludin avatar Dec 02 '25 18:12 Mavludin