Skip to content

Fix invisible reCAPTCHA when multiple widgets are disabled - #3727

Merged
Crabcyborg merged 1 commit into
masterfrom
fix/7011-invisible-recaptcha
Nov 19, 2026
Merged

Crabcyborg merged 1 commit into
masterfrom
fix/7011-invisible-recaptcha

Conversation

@Crabcyborg

@Crabcyborg Crabcyborg commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Fixes https://github.com/Strategy11/formidable-pro/issues/7011

Invisible reCAPTCHA v2 was skipped when Allow multiple reCAPTCHAs was disabled because Google auto-renders that widget without a Formidable widget ID. Allow Google's default widget in that mode and keep the ID requirement for explicitly rendered widgets. Rebuild the minified script and add regression coverage for both rendering modes and for missing or unready widgets.

Testing

  • All 76 JavaScript tests passed, including five new regression cases.
  • Chrome checks with a simulated reCAPTCHA response passed for single-page and final AJAX-page fixtures with multiple reCAPTCHAs disabled, and for an explicitly rendered widget with the setting enabled.
  • Oxlint passed. ESLint reported zero errors and four existing warnings.

Summary by CodeRabbit

  • Bug Fixes
    • Invisible reCAPTCHA forms can now submit when the widget has no ID, the reCAPTCHA API is unavailable, or checking the widget fails.
    • Forms with auto-rendered or explicitly rendered invisible reCAPTCHA widgets continue to follow the appropriate submission behavior.

@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The change updates invisible reCAPTCHA detection for widgets without a data-rid and adds tests for submission behavior, including fallback cases when the API is unavailable or response lookup fails.

Changes: Invisible reCAPTCHA submission

Layer / File(s) Summary
Widget detection and submission tests
js/formidable.js, tests/js/invisibleRecaptcha.test.mjs, eslint.config.mjs
hasInvisibleRecaptcha allows a .g-recaptcha widget without a data-rid when grecaptcha is available. Tests cover auto-rendered and explicitly rendered widgets, missing IDs, unavailable APIs, and response lookup errors. ESLint applies the test-specific override to the new test file.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: franky-the-going-merry

Merge Risk: Minimal · up to cea24

This restores invisible reCAPTCHA submission when multiple reCAPTCHAs are disabled and Google auto-renders the widget without a Formidable ID. Explicitly rendered widgets still require an ID. The new regression tests cover the main paths, and no actionable merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: invisible reCAPTCHA handling when the multiple-widgets setting is disabled. The raw summary says hasInvisibleRecaptcha now accepts an invisible reCAPTCHA without a dat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: invisible reCAPTCHA handling when the multiple-widgets setting is disabled. The raw summary says hasInvisibleRecaptcha now accepts an invisible reCAPTCHA without a data-rid when it has the .g-recaptcha class, and the new tests cover auto-rendered widgets without an ID. The title is specific and matches the changeset and the linked objective.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d5f4f73 and cea2411.

Files ignored due to path filters: 1

  • js/formidable.min.js is excluded by !**/*.min.js
Files selected for processing: 3

  • eslint.config.mjs
  • js/formidable.js
  • tests/js/invisibleRecaptcha.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@Crabcyborg Crabcyborg added this to the 7.1.1 milestone Nov 19, 2026
@deepsource-io

deepsource-io Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

DeepSource Code Review

We reviewed changes in d5f4f73...cea2411 on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
PHP Nov 19, 2026 4:49p.m. Review ↗
JavaScript Nov 19, 2026 4:49p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

querySelector: selector => selector.includes( `.${ widgetClass }[data-size="invisible"]` ) ? widget : null
};
function jQuery() {
return { ready() {}, hasClass: () => true, querySelectorAll: () => [] };

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected empty method 'ready'


Having empty functions hurts readability, and is considered a code-smell. There's almost always a way to avoid using them. If you must use one, consider adding a comment to inform the reader of its purpose.

const { frmFrontForm } = context.window;
context.frmFrontForm = frmFrontForm;
frmFrontForm.submitFormNow = () => calls.push( [ 'submit' ] );
frmFrontForm.submitFormManual( { preventDefault() {} }, form );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected empty method 'preventDefault'


Having empty functions hurts readability, and is considered a code-smell. There's almost always a way to avoid using them. If you must use one, consider adding a comment to inform the reader of its purpose.

@franky-the-going-merry franky-the-going-merry Bot added the franky-working Franky is actively reviewing this label Nov 19, 2026

@franky-the-going-merry franky-the-going-merry Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve. The one-line change in hasInvisibleRecaptcha fixes the reported bug, and I reproduced it before and after.

Live repro, before and after (local preview env, Lite only; Pro was disabled so Lite's own JS is what loads; Google's public test sitekey; Allow multiple reCAPTCHAs off; invisible v2 field; non-AJAX submit):

Build grecaptcha calls on submit g-recaptcha-response at submit Result
base (d5f4f73) none empty "The captcha is missing from this form"
PR (cea2411) reset(undefined), execute(undefined) 1742 chars form submits

The widget markup in that mode is class="g-recaptcha" data-callback="frmAfterRecaptcha" with no data-rid, which is the case the old recaptchaID === undefined guard rejected.

Explicit mode still works: with the setting on, the widget is class="frm-g-recaptcha" data-rid="0"; the PR build ran reset(0), execute(0) and showed "Your responses were successfully submitted."

Tests run: node --test tests/js/invisibleRecaptcha.test.mjs at cea2411 → 5/5 pass. CI skipped every workflow on this head, including JS unit tests, so this was my run. Against the base formidable.js, 2 of the 5 fail (the auto-rendered-widget cases), so they do catch the regression. The other three tests/js files fail locally only because @babel/core isn't installed in my scratch checkout.

Also checked: js/formidable.min.js carries the same change. The .frm-g-recaptcha-only selector in validateRecaptcha isn't affected. grecaptcha.reset(undefined)/execute(undefined) target Google's default widget. The data-callback is already set for this mode in FrmRecaptchaSettings.

Not exercised: the Pro-side submit path (frmProForm) and a multi-page AJAX form. The test file covers the Pro goingToPreviousPage branch with a stub only.

@franky-the-going-merry franky-the-going-merry Bot removed franky-review franky-working Franky is actively reviewing this labels Nov 19, 2026
@Crabcyborg
Crabcyborg merged commit 754c335 into master Nov 19, 2026
62 of 63 checks passed
@Crabcyborg
Crabcyborg deleted the fix/7011-invisible-recaptcha branch November 19, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant