[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) <anv@odoo.com> Signed-off-by: Claude Thibault (thcl) <thcl@odoo.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user