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

[SOLVED] Pressable Event duplicates longPress with navigation #108

Open
DMaxence opened this issue Sep 9, 2024 · 3 comments
Open

[SOLVED] Pressable Event duplicates longPress with navigation #108

DMaxence opened this issue Sep 9, 2024 · 3 comments

Comments

@DMaxence
Copy link

DMaxence commented Sep 9, 2024

I recently updated react-native-ios-context-menu and noticed the behavior is not the same as before.

I have a list of cards and when you click it it navigate to the associated profile page.
Before that, the longpress was correctly handled, but now if I release my finger as soon as I feel the vibration of the longPress, the shortPress fires too.
But if I press long enough, the shortPress is not fired and everything works fine.

Expected behavior

RPReplay_Final1725883798.MP4

Not too long press behavior

RPReplay_Final1725883785.MP4

It was working very well on 1.X

My package.json:

"expo": "^51.0.24",
"@react-navigation/native": "^6.1.6",
"react-native-elements": "^3.4.3",
"react-native-ios-context-menu": "^2.5.1",
"react-native-ios-utilities": "^4.4.5",
"react": "18.2.0",
"react-native": "0.74.3"

The code I use for this :

import { ListItem } from "react-native-elements";
import { ContextMenuView } from "react-native-ios-context-menu";
import { useNavigation } from "@react-navigation/native";

const Card = () => {
  const navigation = useNavigation();

  return (
    <ContextMenuView
      menuConfig={{
        menuTitle: "",
        menuItems: [
          {
            actionKey: "key-00",
            actionTitle: "Edit",
          },
          {
            actionKey: "key-01",
            actionTitle: "Delete",
            menuAttributes: ["destructive"],
          },
        ],
      }}
      onPressMenuItem={({ nativeEvent }) => {
        switch (nativeEvent.actionKey) {
          case "key-00":
            navigation.navigate("EditPartner", { partnerId: partner._id });
            break;
          case "key-01":
            Alert.alert(
              "Are you sure you want to remove this partner?",
              "This action is irreversible and cannot be undone.",
              [
                {
                  text: "Cancel",
                  style: "cancel",
                },
                {
                  text: "Delete",
                  onPress: () => deletePartner(partner._id),
                  style: "destructive",
                },
              ]
            );
            break;
        }
      }}
    >
      <ListItem
        onPress={() =>
          navigation.navigate("Partner", {
            partnerId: partner._id,
          })
        }
      >
        <ListItem.Content>
          <ListItem.Title>
            <Text>Title</Text>
          </ListItem.Title>
        </ListItem.Content>
      </ListItem>
    </ContextMenuView>
  );
};

I can't find anywhere in the doc a navigation inside the ContextMenuView.

@fukemy
Copy link

fukemy commented Oct 7, 2024

I remember other issue fixed it, try to find this issue

@fukemy
Copy link

fukemy commented Oct 7, 2024

look here #9 (comment)

@DMaxence DMaxence changed the title Event not well propagated [SOLVED] Pressable Event duplicates longPress with navigation Oct 8, 2024
@DMaxence
Copy link
Author

DMaxence commented Oct 8, 2024

@fukemy I hadn't looked at the pre-2023 issues because I didn't have the problem with the previous version.
But this fixes my problem thanks 🔥

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

No branches or pull requests

2 participants