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

ContextMenu access on iPad #2029

Open
chiralsystems opened this issue May 10, 2021 · 2 comments
Open

ContextMenu access on iPad #2029

chiralsystems opened this issue May 10, 2021 · 2 comments
Labels
Device: Mobile Issue or pull request is *only* related to Mobile device Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team

Comments

@chiralsystems
Copy link

chiralsystems commented May 10, 2021

I'm submitting a ... (check one with "x")

[ x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

Current behavior

ContextMenu is not accessible when using viewing a primereact 6.3.1 application. The contextMenu is attached to a DataTable. The show case example for contextMenu does not work either

Expected behavior
contextMenu should be displayed on tap long hold

Minimal reproduction of the problem with instructions
Tap long hold on showcase contextmenu example. No contextmenu is shown

Please tell us about your environment:
IOS 14.4.2 iPad

  • React version:
    16.8.0

  • PrimeReact version:
    6.3.1

  • Browser:
    iOS XX Safari iOS Chrome

  • Language:

ES6

@mertsincan
Copy link
Member

Hi,

This is an issue with iOS wherein it does not trigger the contextmenu event on the underlying element. Please see;
https://stackoverflow.com/questions/29228999/jquery-contextmenu-event-not-working-in-ios-8-2/33778163#33778163
There are many issues like this. We use onContextMenu event in our all contextmenu demo pages. Exp;
https://primefaces.org/primereact/showcase/#/contextmenu

<div className="card">
   <ContextMenu model={items} ref={cm}></ContextMenu>

   <img onContextMenu={(e) => cm.current.show(e)} .../> // This <img> element is entirely a user-defined element.
</div>

Therefore, maybe you can simulate contextmenu event using touchstart, touchmove and touchend events.
Best Regards,

@melloware melloware added the Device: Mobile Issue or pull request is *only* related to Mobile device label Apr 16, 2022
@melloware
Copy link
Member

Here is a great component you could use: https://github.com/minwork/use-long-press

Something like...

import React from 'react';
import { useLongPress } from 'use-long-press';

const Example = () => {
  const cm = useRef(null);

  const bind = useLongPress(() => {
    console.log('Long pressed!');
   cm.current.show(e)
  });

  return (
        <ContextMenu model={items} ref={cm}></ContextMenu>
        <img {...bind()} />
   }
};

@melloware melloware added the Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team label Apr 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Device: Mobile Issue or pull request is *only* related to Mobile device Resolution: Workaround Issue or pull request contains a workaround. It needs to be reviewed further by Core Team
Projects
None yet
Development

No branches or pull requests

3 participants