-
Notifications
You must be signed in to change notification settings - Fork 10
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
Replaces click #2
base: master
Are you sure you want to change the base?
Conversation
I tried this and it didn't work for me on Chrome on Mac and iPhone. The click event still registers and the handler is fired. While testing I also noticed that this doesn't prevent force touch events from occurring on phones that support it. In my case an image inside the button would pop out and offer itself for sharing or saving. |
@kaechele thats odd, I developed it on Chrome on a Mac, it sure works for me. Did you do a rebuild? |
I did some more debugging. Seems to be a problem when this is used in conjunction with BootstrapVue. |
So BootstrapVue re-implements the click handler on the b-button component. That re-implementation doesn't honour stopPropagation from inner functions at all. So the @click handler is fired regardless. |
B-button just forwards the native click event up. So you probably need to check if |
I ended up getting lazy and am working around it like this: https://jsfiddle.net/kaechele/s46xgjdz/ |
@tmorehouse |
Ah.. you might be able to check if bubbling was prevented then... |
Since b-button is a functional component, its click event is the native button's event. maybe |
According to MDN:
Do we have any guarantee that |
|
If your button isn't doing anything fancy, you could just use a button like this: <button class="btn btn-primary" v-longclick="() => longClick()" @click="shortClick">
Button
</button> Since b-button is just a functional component, it adds it's click handler (really the user's click handler) as it is rendered... so it probably gets attached before the directive event handler does. |
Hey, first of all great lib - none of the other seem to handle both mouse and touch events correctly. I am trying to use this lib to trigger actions on items in a list (i.e. hold to delete), but I wanted to avoid actually selecting the item. I've added a param which suppresses the click event if a long click is triggered.