You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix invisible reCAPTCHA when multiple widgets are disabled - #3727
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.
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.
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: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
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
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
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.
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.
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.
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.
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.
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Summary by CodeRabbit