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

fixes backdrop flash when content height is increasing

Open somebody32 opened this issue 4 years ago • 9 comments

Motivation

This PR fixes https://github.com/gorhom/react-native-bottom-sheet/issues/436.

The culprit of the issue was a sudden drop in animatedIndex because of the height change, so the approach is to detect if the animatedIndex achieved max value already (ie backdrop appeared fully) and then interpolate only if animatedIndex values start to decrease.

Another important topic is how to render the backdrop itself. The doc suggests something like that:

const renderBackdrop = useCallback(
    (props: BottomSheetBackdropProps) => (
      <BottomSheetBackdrop {...props} />
    ),
    []
  );

which, surprisingly, causes flicker sometimes because react unmounts and mounts the backdrop on height changes. The fix is to add key prop:

const renderBackdrop = useCallback(
    (props: BottomSheetBackdropProps) => (
      <BottomSheetBackdrop key="backdrop" {...props} />
    ),
    []
  );

Video

https://user-images.githubusercontent.com/25742/128371308-4359284b-1ddc-4114-9a23-6c839b118ed0.mp4

somebody32 avatar Aug 05 '21 14:08 somebody32

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

github-actions[bot] avatar Sep 07 '21 09:09 github-actions[bot]

@gorhom commenting as soon as this is still mergeable

somebody32 avatar Sep 07 '21 10:09 somebody32

i will look into this pr this weekend, thanks for submitting it @somebody32

gorhom avatar Sep 08 '21 19:09 gorhom

@gorhom ping

jcgertig avatar Oct 13 '21 01:10 jcgertig

@gorhom ping

Jungwoo-An avatar Nov 01 '21 02:11 Jungwoo-An

I still have this problem in the latest version (v4).

If I have multiple bottom sheets inside a screen and a TextInput not inside any of the bottom sheets blurs, the animated index changes for a split second and the backdrop flashes.

Any ideas? @somebody32

fluorescent23 avatar Jul 26 '23 22:07 fluorescent23

@somebody32 anyway to integrate this fix till it gets merged?

badalsaibo avatar Mar 03 '24 09:03 badalsaibo

This PR is way out of date and should probably be closed.

joshsmith avatar Mar 04 '24 18:03 joshsmith