Skip to content

Fix onSwipeableWillClose called on opening of ReanimatedSwipeable #3478

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

m-bert
Copy link
Contributor

@m-bert m-bert commented Apr 7, 2025

Description

Apparently faulty logic in ReanimatedSwipeable makes onSwipeableWillClose callback being triggered right after opening swipeable. This PR fixes that behavior.

Fixes #3475

Test plan

Tested on the following code:
import React from 'react';
import { View, Text } from 'react-native';
import Swipeable from 'react-native-gesture-handler/ReanimatedSwipeable';

export default function Example() {
  return (
    <Swipeable
      renderLeftActions={() => {
        return (
          <View style={{ height: 80, width: 80, backgroundColor: 'yellow' }}>
            <Text>Left</Text>
          </View>
        );
      }}
      renderRightActions={() => {
        return (
          <View style={{ height: 80, width: 80, backgroundColor: 'magenta' }}>
            <Text>Right</Text>
          </View>
        );
      }}
      onSwipeableWillClose={() => console.log('Will close')}>
      <View
        style={{
          height: 80,
          backgroundColor: 'blue',
        }}
      />
    </Swipeable>
  );
}

@m-bert m-bert requested a review from latekvo April 7, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReanimatedSwipeable: onSwipeableClose is triggered when onSwipeableOpen is not set
1 participant