From 0e086fe0e953a767962597b32d43058eb6dcf654 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Thu, 28 Nov 2024 09:38:56 +0100 Subject: [PATCH] Card selection UI stuck when history back option is used, dirty fix --- .../views/frontend/tpl/stripecreditcard.tpl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Application/views/frontend/tpl/stripecreditcard.tpl b/Application/views/frontend/tpl/stripecreditcard.tpl index 66cad56..9de3ea9 100644 --- a/Application/views/frontend/tpl/stripecreditcard.tpl +++ b/Application/views/frontend/tpl/stripecreditcard.tpl @@ -125,10 +125,18 @@ $stripeRadio.trigger('click'); } - // Reset used card selection when Stripe is selected - if ($stripeRadio.is(':checked')) { - $stripeUsedCardSelect.prop('selectedIndex', 0); - } + //this is a dirty fix for selecting firs card selection element so the card UI not stuck when customer + // uses the browsers history back + setTimeout(function (){ + const $stripeCardDD = $stripeRadio.parents('dt').next('dd'); + const $stripeUsedCardSelect = $stripeCardDD.find('#stripe_used_card'); + + // Reset used card selection when Stripe is selected + if ($stripeRadio.is(':checked')) { + $stripeUsedCardSelect.prop('selectedIndex', 0); + } + + }, 200); });