diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js index 0321bf70..7c9cf630 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js @@ -126,6 +126,9 @@ define( registry.captchaList.push(widgetId); registry.tokenFields.push(this.tokenField); + let captchaId = this.getReCaptchaId(); + registry.captchaListDetails.push([widgetId] = captchaId); + }, /** @@ -180,6 +183,39 @@ define( me.initCaptcha(); }); } + + let captchaListDetails = registry.captchaListDetails(); + + if (this.getIsInvisibleRecaptcha() && this.getReCaptchaId()) { + + let captchaReloaded = false; + + $(".product.data.items").on("dimensionsChanged", function (event, data) { + if (captchaReloaded == false) { + let opened = data.opened; + + if (opened) { + + if (event.target && event.target.hasAttribute('aria-controls')) { + + let ariaControls = event.target.getAttribute('aria-controls'); + + if ($('#' + ariaControls).has('#' + this.getReCaptchaId()).length) { + let keys = captchaListDetails.keys(), + key; + + for (key of keys) { + if (captchaListDetails[key] == this.getReCaptchaId()) { + grecaptcha.reset(key); + captchaReloaded = true; + } + } + } + } + } + } + }.bind(this)); + } }, /** diff --git a/ReCaptchaFrontendUi/view/frontend/web/js/registry.js b/ReCaptchaFrontendUi/view/frontend/web/js/registry.js index 2ff47a0c..2cabbdd1 100644 --- a/ReCaptchaFrontendUi/view/frontend/web/js/registry.js +++ b/ReCaptchaFrontendUi/view/frontend/web/js/registry.js @@ -9,6 +9,7 @@ define(['ko'], function (ko) { return { ids: ko.observableArray([]), captchaList: ko.observableArray([]), + captchaListDetails: ko.observableArray([]), tokenFields: ko.observableArray([]) }; });