Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions js/formidable.js
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,24 @@ function frmFrontFormJS() {
grecaptcha.execute( recaptchaID );
}

/**
* The invisible reCAPTCHA widget has no error/expired callback wired up, so a
* stalled or failed check would otherwise leave the submit button disabled
* with no way to retry. Only re-enable if the check itself never resolved -
* once it has, the form is submitting for real and its own ajax lifecycle
* owns the button state.
*
* @param {HTMLElement} object Form object.
* @return {void}
*/
function reenableSubmitIfRecaptchaStalls( object ) {
setTimeout( function() {
if ( object.classList.contains( 'frm_loading_form' ) && hasInvisibleRecaptcha( object ) ) {
removeSubmitLoading( jQuery( object ), 'enable' );
}
}, 10000 );
}

function validateRecaptcha( form, errors ) {
const formEl = form instanceof jQuery ? form.get( 0 ) : form;
if ( ! formEl ) {
Expand Down Expand Up @@ -2434,12 +2452,12 @@ function frmFrontFormJS() {

const invisibleRecaptcha = hasInvisibleRecaptcha( object );

showSubmitLoading( jQuery( object ) );

if ( invisibleRecaptcha ) {
showLoadingIndicator( jQuery( object ) );
executeInvisibleRecaptcha( invisibleRecaptcha );
reenableSubmitIfRecaptchaStalls( object );
} else {
showSubmitLoading( jQuery( object ) );

frmFrontForm.submitFormNow( object );
}
},
Expand Down
Loading