google-pay-button icon indicating copy to clipboard operation
google-pay-button copied to clipboard

onClick preventDefault is not working in Vue integration

Open hassanAwanAlvi opened this issue 1 year ago • 1 comments

Describe the bug A clear and concise description of what the bug is. I am using Vite / Vue and I am trying to preventDefault in google-pay-button's onClick. But I've tried a low of different ways and it seems to have some bug.

To Reproduce Steps to reproduce the behavior:

  1. Install the component in Vue
  2. do @click="(event)=> {event.preventDefault()}"
  3. It will still open the payment sheet.

Expected behavior It should prevent the payment sheet.

Screenshots NA Component information:

  • Component
    • [ ] Custom element (@google-pay/button-element) Component version (e.g. 3.1.0):

Environment:

  • Device iMac
  • OS (e.g. 14.2.1 (23C71)):
  • Browser (e.g. Chrome)
  • Country/region: UK

Please don't hesitate to ask me any further questions. Looks like this line has some issues.

const request = this.createLoadPaymentDataRequest(config); try { if (config.onClick) { config.onClick(event); } if (event.defaultPrevented) { return; }

hassanAwanAlvi avatar May 09 '24 13:05 hassanAwanAlvi

@hassanAwanAlvi did you check how we do it for our Vue example?

https://github.com/google-pay/google-pay-button/blob/e1bfb1e3d1f43ad85ef00b631b651cc7a5e03823/examples/vue/src/components/Examples.vue#L236

Like this it works for me and the Google Pay sheet is not shown.

dmengelt avatar May 23 '24 09:05 dmengelt

I did check, I was doing this but its not working I ama happy to connect and show you more.

hassanAwanAlvi avatar Aug 06 '24 09:08 hassanAwanAlvi

@hassanAwanAlvi please share a full reproducer on a site like stackblitz.com

dmengelt avatar Aug 06 '24 09:08 dmengelt

closing due to no activity

dmengelt avatar Sep 02 '24 08:09 dmengelt