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] | [v2] Index log -1 on small snapPoints from portrait to landscape #1589

Closed
emendo-web opened this issue Oct 23, 2023 · 8 comments
Closed
Labels
bug Something isn't working no-issue-activity

Comments

@emendo-web
Copy link

emendo-web commented Oct 23, 2023

Bug

When you change orientation of device (portrait to landscape ONLY) the bug will be appear.
On small snapPoints we can see log with -1 as value.
If you change orientation with a big snapPoints. index will be not pass to -1

Environment info

Library Version
@gorhom/bottom-sheet ^4.5.1
expo ~49.0.15
expo-status-bar ~1.6.0
react 18.2.0
react-native 0.72.6
react-native-reanimated ~3.3.0
react-native-gesture-handler" ~2.12.0

Steps To Reproduce

  • Clone the repository below on Reproducible sample code
  1. Install expo app
  2. Clone the repository below
  3. Install dependencies
  4. npm run android -- -c

Describe what you expected to happen:
On small snapPoints and when the orientation changes, the index should not pass to -1

  1. Start the app in portrait
  2. Set the snapPoints at index 0
  3. Change orientation to landscape. You will see in log "handleSheetChanges -1"
  4. Come back to portrait. Log work correctly.
  5. If you trying to repeat the same step but with index 1. The bug will be not appear

Reproducible sample code

Reproducible repo: https://github.com/emendo-web/bs-orientation.git

@emendo-web emendo-web added the bug Something isn't working label Oct 23, 2023
@joeporpeglia
Copy link

joeporpeglia commented Oct 31, 2023

This is causing the active bottom sheet to close when users change device orientation on iOS. In my case, I'm passing enabledDynamicSizing with a BottomSheetScrollView and no snapPoints.

Copy link

github-actions bot commented Dec 1, 2023

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.

@cyrilmarceau
Copy link

cyrilmarceau commented Dec 1, 2023

Same problem

@hraschan
Copy link

hraschan commented Dec 7, 2023

@joeporpeglia Did you find a workaround?

Getting the following logs:

LOG handleSheetChanges 0
LOG handleSheetChanges -1
LOG handleSheetChanges 0

But the modal still disappears when changing to landscape mode

@joeporpeglia
Copy link

No unfortunately I haven't been able to fix

Copy link

github-actions bot commented Jan 7, 2024

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.

Copy link

This issue was closed because it has been stalled for 5 days with no activity.

@eithe
Copy link

eithe commented Mar 1, 2024

Also seeing the same.

I had to put in place a quite hackish workaround where I wait 100ms before doing my onDrop-logic (which is cancelled if there is a another sheet change before 100ms has passed).

import { debounce } from 'lodash';
...
  const debouncedOnDrop = useRef(debounce(onDrop, 100)); // https://github.com/gorhom/react-native-bottom-sheet/issues/1589
  const snapPointsCached = useMemo(() => snapPoints, [snapPoints]);

  const onChange = useCallback(
    (index: number) => {
      if (index === -1) {
        debouncedOnDrop.current();
      } else {
        if (debouncedOnDrop?.current?.cancel) {
          debouncedOnDrop.current.cancel();
        }
        onSheetChanged(index);
      }
    },
    [onSheetChanged],
  );

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

No branches or pull requests

5 participants