Skip to content

[50$] Feature Request / Bug Report - iOS / Android onPress action for <ContextMenu.Trigger> that doesn't conflict with normal the actual ContextMenu Deployment #145

Open

Description

@ChristopherGabba

First of all, I want to show my sincere appreciation for this library and all the wonderful docs. Its absolutely phenomenal.

This issue has sort of been bothering me in our app for a while. There is a "workaround" available for iOS, which I'm not a huge fan of, but it's still flaky on Android.

Desired Functionality:
I wrap my some content in my app with a <ContextMenu>. That content is a wrapped in a TouchableOpacity. The functionality I desire is:

  1. User quickly taps on that content, it takes them to play the video or full screen the image (similar to the repro)
  2. If a user long presses on the content, they can "Share", "Comment" or "Delete" (all options within my Context Menu)

The Problem
The onPress of my "Touchable" currently interacts with the deployment of the <ContextMenu/>. When you long tap on the context menu it also fires the onPress of the button. Here is a video of the issue.

The Workaround (Identified here)
On iOS the workaround fairly solid. You essentially make the onLongPress of the inner Touchable an empty function like so:

      <ContextMenu.Trigger action="longPress">
        <TouchableOpacity
          onPress={onQuickPress}
          /**THIS IS A WORKAROUND TO AVOID ACCIDENTAL FIRING OF BUTTON */
          onLongPress={() => {}} 
          activeOpacity={0.7}
        >
          {children}
        </TouchableOpacity>
      </ContextMenu.Trigger>

Video Detailing Issue
https://github.com/user-attachments/assets/7e0e58e9-1285-4d54-936e-db4f2b297964

Note: It seems to work well on iOS and Android via simulator, but in reality, just scrolling on a real android device triggers this context menu sometimes. It's just not an ideal user experience. Really this needs a real solution where the context menu itself has its on onPress event that handles all of this stuff.

Reproduction:

  1. Clone Repro: https://github.com/ChristopherGabba/ContextMenu-Press-Repo
  2. Run yarn install
  3. Run npx expo run:ios --device / npx expo run:android --device

Note:
There are quite a few related issues that detail this exact topic:

Activity

  1. krevnekak commented on Mar 21, 2025

    @krevnekak

    same problem

  2. bogdandobritoiu commented on Apr 16, 2025

    @bogdandobritoiu

    I've encountered the same issue but not with DropdownMenu.

    Solution is to have a state for disable and add a TouchableOpacity around the entire DropdownMenu.

    const [isLongPressActive, setIsLongPressActive] = useState(false)
    
    const handlePress = useCallback(() => {
        if (!isLongPressActive) {
          [what you want it to do after normal press]
        }
        setTimeout(() => {
          setIsLongPressActive(false)
        }, 100)
      }, [isLongPressActive, onPress, item])
    
      const handleLongPress = useCallback(() => {
        setIsLongPressActive(true)
      }, [])
    
      const handlePressOut = useCallback(() => {
        setTimeout(() => {
          setIsLongPressActive(false)
        }, 100)
      }, [])
    
    <TouchableOpacity
          onPress={handlePress}
          onLongPress={handleLongPress}
          onPressOut={handlePressOut}
          delayLongPress={200}>
         <Root>
             <Content>
                 [...]
             </Content>
             <DropdownMenu.Trigger disabled={!isLongPressActive} action="longPress">
                [button]
             </DropdownMenu.Trigger>
         </Root>
    </TouchableOpacity>
    

    Hope this helps. I've tried using gesture handler too but it didn't work as expected. Use a native Touchable or Pressable to wrap the entire menu.
    This fixed my android issue of tapping the button and it still opened the menu for some reason (Exactly as your case shows in the video)

  3. smanzler commented on May 15, 2025

    @smanzler

    same issue, I am going to use the same workout around setting onLongPress to () => {}

  4. vladislav-gorovenko commented on Jul 17, 2025

    @vladislav-gorovenko

    Thanks for workaround

  5. hlog2e commented on Jan 7, 2026

    @hlog2e

    Same here — I can reproduce this on my side too. The only way I’ve been able to make it work is by using a hack like onLongPress={() => {}} (no-op). It feels like the only practical workaround right now. Hoping there’s a real fix upstream.

  6. richardo2016 commented on Jan 7, 2026

    @richardo2016

    This seems to be a type of problem I've solved before (although the performance isn't 100% identical, I believe the underlying cause is the same).

    @ChristopherGabba I'd like to ask if this bounty is still valid? If it is, I can provide a PR and demo video (based on a real device, not a simulator) for the repository you provide. If you confirm it's valid, you can pay me the bounty via Apple gift card or crypto.

  7. mateofowlerz commented on Jan 12, 2026

    @mateofowlerz

    This seems to be a type of problem I've solved before (although the performance isn't 100% identical, I believe the underlying cause is the same).

    @ChristopherGabba I'd like to ask if this bounty is still valid? If it is, I can provide a PR and demo video (based on a real device, not a simulator) for the repository you provide. If you confirm it's valid, you can pay me the bounty via Apple gift card or crypto.

    i'll pay u the bounty if the pr gets merged into Zeego. I hate this workaround

  8. richardo2016 commented on Jan 12, 2026

    @richardo2016

    This seems to be a type of problem I've solved before (although the performance isn't 100% identical, I believe the underlying cause is the same).
    @ChristopherGabba I'd like to ask if this bounty is still valid? If it is, I can provide a PR and demo video (based on a real device, not a simulator) for the repository you provide. If you confirm it's valid, you can pay me the bounty via Apple gift card or crypto.

    i'll pay u the bounty if the pr gets merged into Zeego. I hate this workaround

    Hi, maybe you don't need a pr merged into the zeego, you can use patch-package or yarn package to make your workaround available in your repository

  9. mateofowlerz commented on Jan 12, 2026

    @mateofowlerz
  10. mateofowlerz commented on Jan 12, 2026

    @mateofowlerz

    The workaround wasn't working 100% of the time for me and adding the delay solved it.

    onPress={handlePress} onLongPress={() => {}} delayLongPress={100}

    Source: dominicstop/react-native-ios-context-menu#9 (comment)

  11. orgorin023 commented on Jun 16, 2026

    @orgorin023

    Opened PR #196 with a native long-press trigger fix: https://github.com/nandorojo/zeego/pull/196\n\nIt wraps the trigger child press handler only for native long-press triggers so the trailing press after the context menu opens is swallowed once, while normal press behavior resumes afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions