vue-touch-events icon indicating copy to clipboard operation
vue-touch-events copied to clipboard

Suppress browser context menu when using touchhold

Open GregPeden opened this issue 4 years ago • 4 comments

Browsers like Chrome will present the context menu on a long press, which conflicts with UI functions that expect the same. This happens on desktop and mobile. Would it be feasable to suppress the browser context menu when touchhold is used?

GregPeden avatar May 12 '20 21:05 GregPeden

Using @contextmenu.prevent on a component suppresses context so I suppose leave it to the package user to implement this, but perhaps document this.

GregPeden avatar May 12 '20 21:05 GregPeden

So, is your issue solved? 🤔

jerrybendy avatar May 13 '20 06:05 jerrybendy

Seems to be, but he kinda want them to document it somewhere =)

lucasctd avatar May 21 '20 01:05 lucasctd

I have the same problem, but @contextmenu.prevent don't work. It prevents also v-touch:touchhold.

<my-component v-touch:touchhold='onLongTap' @contextmenu.prevent>

One working solution for mobile ad desktop browser

<my-component v-touch:touchhold='onLongTap'  @contextmenu='onLongTap'>

with event handler:

export default {
  methods: {
    onLongTap(event) {
      event.preventDefault()
      /* do what you want here... */
    },
  }
}

phlegx avatar Nov 10 '20 18:11 phlegx