Skip to content

Commit cd225d7

Browse files
authored
Fix mCaptcha bug (#33659)
Fix #33658
1 parent e6759f3 commit cd225d7

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

web_src/css/form.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ textarea:focus,
243243
height: 76px !important;
244244
}
245245
.m-captcha-style {
246-
width: 50%;
246+
max-width: 450px;
247247
}
248248
}
249249

web_src/js/features/captcha.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ export async function initCaptcha() {
3434
break;
3535
}
3636
case 'm-captcha': {
37-
const {default: mCaptcha} = await import(/* webpackChunkName: "mcaptcha-vanilla-glue" */'@mcaptcha/vanilla-glue');
38-
// @ts-expect-error
37+
const mCaptcha = await import(/* webpackChunkName: "mcaptcha-vanilla-glue" */'@mcaptcha/vanilla-glue');
38+
39+
// FIXME: the mCaptcha code is not right, it's a miracle that the wrong code could run
40+
// * the "vanilla-glue" has some problems with es6 module.
41+
// * the INPUT_NAME is a "const", it should not be changed.
42+
// * the "mCaptcha.default" is actually the "Widget".
43+
44+
// @ts-expect-error TS2540: Cannot assign to 'INPUT_NAME' because it is a read-only property.
3945
mCaptcha.INPUT_NAME = 'm-captcha-response';
4046
const instanceURL = captchaEl.getAttribute('data-instance-url');
4147

42-
// @ts-expect-error
43-
mCaptcha.default({
48+
new mCaptcha.default({
4449
siteKey: {
4550
instanceUrl: new URL(instanceURL),
4651
key: siteKey,

0 commit comments

Comments
 (0)