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

Enhancement: Handle onPanResponderTerminate for Toasts in Dismissible iOS Modals #184

Open
landabaso opened this issue Jan 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@landabaso
Copy link

landabaso commented Jan 15, 2024

I would like to propose an enhancement for handling Toast components within dismissible modals on iOS. I've encountered an issue where gesture conflicts arise when a Toast is displayed inside a modal that can be dismissed with a swipe gesture.

I suggest adding an onPanResponderTerminate handler:

      // This fix addresses an issue specific to iOS when using Modals.
      // If the Toast component is displayed within an iOS Modal and the user
      // initiates a swipe gesture to dismiss the Toast, there's a potential for
      // gesture conflicts. When a swipe right/left gesture is started within
      // the Toast, followed by a swipe up/down gesture in the
      // Modal, the Modal itself captures the gesture, interrupting the Toast's
      // gesture handling.
      // This results in the Toast's PanResponder receiving a termination
      // request.
      // The fix below ensures that when such a termination request occurs,
      // the Toast smoothly returns to its original position or completes,
      // thus maintaining a consistent and expected user experience.
      // If not handled, the Toast remains in an indeterminate position since
      // onPanResponderRelease is never received.
      onPanResponderTerminate: (_, gestureState) => {
        if (gestureState.dx > 50) {
          panReleaseToRight(gestureState);
        } else if (gestureState.dx < -50) {
          panReleaseToLeft(gestureState);
        } else {
          Animated.spring(getPanResponderAnim(), {
            toValue: { x: 0, y: 0 },
            useNativeDriver: Platform.OS !== "web",
          }).start();
        }
      }
@landabaso landabaso added the bug Something isn't working label Jan 15, 2024
@andandrej
Copy link

This is the same problem as #181 I think? @landabaso

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

2 participants