From f09482c57ffee2ce37ffe394def66e8f64ef66ea Mon Sep 17 00:00:00 2001 From: thcl-odoo Date: Mon, 22 Nov 2021 14:16:22 +0000 Subject: [PATCH] [FIX] payment: use correct target on onclick event Current behavior : If we click on the icon rather than the label we got a crash Steps to reproduce : - Enable Online Payment and configure an acquirer and add the possibility to save the card - Go to the Website and Log in (e.g. as `Marc Demo`) - Go to your account (from dropdown menu > `My Account`) - Manage you payment methods and add a new one - Try to delete the newly added payment method by clicking on the trash icon in the button Reason : Currently, we rely on the `target` property of the event (triggered after clicking on the button). The problem is that, as in this case, if a button has an HTML element as a child and we click on this child, `target` property will target the child whereas in this case we want to retrieve the button and not the child. Using `currentTarget` property instead of `target` allows us to retrieve the button no matter what since `currentTarget` always refers to the element to which the event handler has been attached. OPW-2660186 closes odoo/odoo#80253 X-original-commit: e8ec4fb6aa9ee4796d486a3d32e6a9a5e1382548 Signed-off-by: Antoine Vandevenne (anv) Signed-off-by: Claude Thibault (thcl) --- addons/payment/static/src/js/manage_form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/payment/static/src/js/manage_form.js b/addons/payment/static/src/js/manage_form.js index ce5a1330769..ccecfe49bf2 100644 --- a/addons/payment/static/src/js/manage_form.js +++ b/addons/payment/static/src/js/manage_form.js @@ -171,7 +171,7 @@ odoo.define('payment.manage_form', require => { ev.preventDefault(); // Extract contextual values from the delete button - const linkedRadio = $(ev.target).siblings().find('input[name="o_payment_radio"]')[0]; + const linkedRadio = $(ev.currentTarget).siblings().find('input[name="o_payment_radio"]')[0]; const tokenId = this._getPaymentOptionIdFromRadio(linkedRadio); // Delete the token