Skip to content

Commit 674b8db

Browse files
#224: Recaptcha badge is not shown on checkout login form if 'Invisible Badge Position' is 'Bottom Left/Right'
Merge pull request #5738 from magento-honey-badgers/2.4-develop-241-sync [honey] MC-33700: TransportBuilder unable to send emails of Content-Type "text/plain"
1 parent c062d18 commit 674b8db

File tree

2 files changed

+51
-2
lines changed

2 files changed

+51
-2
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Copyright © Magento, Inc. All rights reserved.
3+
* See COPYING.txt for license details.
4+
*/
5+
6+
define([
7+
'jquery'
8+
], function ($) {
9+
'use strict';
10+
11+
var reCaptchaEntities = [],
12+
initialized = false,
13+
rendererRecaptchaId = 'recaptcha-invisible',
14+
rendererReCaptcha = null;
15+
16+
return {
17+
add: function (reCaptchaEntity, parameters) {
18+
if (parameters.size === 'invisible' && parameters.badge !== 'inline') {
19+
if (!initialized) {
20+
this._init();
21+
grecaptcha.render(rendererRecaptchaId, parameters);
22+
setInterval(this._resolveVisibility, 100);
23+
initialized = true;
24+
}
25+
26+
reCaptchaEntities.push(reCaptchaEntity);
27+
}
28+
},
29+
30+
_resolveVisibility: function () {
31+
reCaptchaEntities.some(
32+
(entity) => {
33+
return entity.is(":visible")
34+
// 900 is some magic z-index value of modal popups.
35+
&& (entity.closest("[data-role='modal']").length == 0 || entity.zIndex() > 900)
36+
}) ? rendererReCaptcha.show() : rendererReCaptcha.hide();
37+
},
38+
39+
_init: function () {
40+
rendererReCaptcha = $('<div/>', {
41+
'id': rendererRecaptchaId
42+
});
43+
$('body').append(rendererReCaptcha);
44+
}
45+
};
46+
});

ReCaptchaFrontendUi/view/frontend/web/js/reCaptcha.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ define(
1111
'jquery',
1212
'ko',
1313
'Magento_ReCaptchaFrontendUi/js/registry',
14-
'Magento_ReCaptchaFrontendUi/js/reCaptchaScriptLoader'
14+
'Magento_ReCaptchaFrontendUi/js/reCaptchaScriptLoader',
15+
'Magento_ReCaptchaFrontendUi/js/nonInlineReCaptchaRenderer',
1516
],
16-
function (Component, $, ko, registry, reCaptchaLoader, undefined) {
17+
function (Component, $, ko, registry, reCaptchaLoader,nonInlineReCaptchaRenderer, undefined) {
1718
'use strict';
1819

1920
return Component.extend({
@@ -117,6 +118,8 @@ define(
117118
this.settings.rendering
118119
);
119120

121+
nonInlineReCaptchaRenderer.add($reCaptcha, parameters);
122+
120123
// eslint-disable-next-line no-undef
121124
widgetId = grecaptcha.render(this.getReCaptchaId(), parameters);
122125
this.initParentForm($parentForm, widgetId);

0 commit comments

Comments
 (0)