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

[v4] Request: smoother keyboard transition when the bottom sheet is dismissed programmatically

Open SimpleCreations opened this issue 4 years ago • 94 comments

Feature Request

Currently, when the bottom sheet is dismissed via the dismiss method while the keyboard is open, the sheet first slides all the way under the keyboard, and the keyboard then stays on screen for about a second before disappearing.

This feels like a performance issue from the UX perspective, and it would be great if the keyboard started sliding down along with the bottom sheet at the same time, thus eliminating the delay.

Demo of the current behavior:

https://user-images.githubusercontent.com/12449725/133307532-c01d43bd-025c-4f5c-9d87-5af074d5b28a.mp4

Why it is needed

Possible implementation

Code sample

SimpleCreations avatar Sep 14 '21 17:09 SimpleCreations

This PR just got merged: https://github.com/facebook/react-native/pull/31402

It will fix all of our weird keyboard issues soon :)

hirbod avatar Sep 26 '21 09:09 hirbod

i think the solution would be, to close keyboard when modal gets dismiss and keyboard was opened by the sheet 💡

gorhom avatar Oct 03 '21 10:10 gorhom

@gorhom the issue is that onDismiss seems to get called after the modal is dismissed, not when the user initiates the dismiss. Is there a way to detect when the user pressed the backdrop, or initiated the dismiss?

mattgabor avatar Oct 13 '21 17:10 mattgabor

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 13 '21 09:11 github-actions[bot]

This is still an issue, please remove stale label.

mattgabor avatar Nov 14 '21 00:11 mattgabor

This is still an issue, please remove stale label.

if u want you can use onAnimate to HOTFIX this, its only option in our project, sadly this "fix" or "cheat" work only with 1 snap point :/

onAnimate={(from, to) => { if (to === -1) { // Keyboard.dismiss(); } }}

Engazan avatar Dec 04 '21 18:12 Engazan

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 Jan 04 '22 09:01 github-actions[bot]

Not stale

SimpleCreations avatar Jan 04 '22 11:01 SimpleCreations

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 Feb 05 '22 09:02 github-actions[bot]

Not stale

SimpleCreations avatar Feb 05 '22 10:02 SimpleCreations

This PR just got merged: facebook/react-native#31402

It will fix all of our weird keyboard issues soon :)

This was finally merged in December after being reverted, but it looks like it's scoped for the RN 0.68 release. When you say this will fix the issue, do you mean that the author of react-native-bottom-sheet will have to implement the automaticallyAdjustKeyboardInsets prop or we can just include it in the scrollviews within the bottom sheet?

mattgabor avatar Feb 07 '22 00:02 mattgabor

Afaik it's part of 0.67 and already shipped. You need to add the prop to your scrollview

hirbod avatar Feb 07 '22 02:02 hirbod

What if you don't use a ScrollView? I get this issue even when I just have a vanilla View inside of the BottomSheetModal.

jzxchiang1 avatar Feb 14 '22 00:02 jzxchiang1

Calling Keyboard.dismiss() from a TouchableWithoutFeedback that I pass to the backdropComponent prop works great for me.

antFrancon avatar Mar 12 '22 18:03 antFrancon

~~I ended up just adding Keyboard.dismiss() to this line of BottomSheetBackdrop using patch-package and it fixed it: https://github.com/gorhom/react-native-bottom-sheet/blob/0010008906154f9a545f89d5826ea7af48336610/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx#L45-L47~~

See @hirbod's solution below

mattgabor avatar Mar 22 '22 00:03 mattgabor

@mattgabor why are you using patch-package for this?

import { BottomSheetBackdrop, BottomSheetBackdropProps, BottomSheetModal } from '@gorhom/bottom-sheet';

const renderBackdrop: React.FC<BottomSheetBackdropProps> = (props) => {
  return (
    <BottomSheetBackdrop {...props} appearsOnIndex={0} disappearsOnIndex={-1}>
      <Pressable onPress={Keyboard.dismiss} style={{ flex: 1}} />
    </BottomSheetBackdrop>
  );
};

<BottomSheet
    ...
    backgroundComponent={renderBackground}
>
...

hirbod avatar Mar 22 '22 00:03 hirbod

@hirbod thanks for the suggestion, this worked! Previously I was rendering the backdrop as a child of pressable which was incorrect.

mattgabor avatar Mar 22 '22 00:03 mattgabor

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 Apr 21 '22 09:04 github-actions[bot]

Still relevant

SimpleCreations avatar Apr 21 '22 09:04 SimpleCreations

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 May 22 '22 09:05 github-actions[bot]

Not stale

SimpleCreations avatar May 22 '22 09:05 SimpleCreations

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 Jun 23 '22 09:06 github-actions[bot]

Not stale

SimpleCreations avatar Jun 23 '22 11:06 SimpleCreations

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 Jul 24 '22 09:07 github-actions[bot]

Not stale

SimpleCreations avatar Jul 24 '22 10:07 SimpleCreations

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 Aug 25 '22 09:08 github-actions[bot]

Not stale

SimpleCreations avatar Aug 25 '22 09:08 SimpleCreations

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 Sep 25 '22 09:09 github-actions[bot]

Not stale

SimpleCreations avatar Sep 25 '22 11:09 SimpleCreations

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 27 '22 09:10 github-actions[bot]