Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion js/formidable.js
Original file line number Diff line number Diff line change
Expand Up @@ -1507,9 +1507,12 @@ function frmFrontFormJS() {
summary.focus();
return;
}
// Summary was resolved active server-side but isn't in the DOM on this path (e.g.
// js_validate's client-only validation never renders it) - fall back to the first
// error field instead of leaving focus nowhere.
}

if ( ! config.focusFirstError ) {
if ( ! config.focusFirstError && ! config.focusErrorSummary ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion js/formidable.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions tests/cypress/e2e/Forms/fieldsInFormBuilder-validation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ describe( 'Fields in the form builder', () => {
cy.get( `[id^="frm_error_field_"]` ).eq( 0 ).should( 'contain', `Text cannot be blank.` );
cy.get( `[id^="frm_error_field_"]` ).eq( 1 ).should( 'not.exist' );
cy.get( `[id^="frm_error_field_"]` ).eq( 2 ).should( 'not.exist' );
// js_validate's client-side path never renders the error summary markup - focus must
// fall back to the first errored field instead of going nowhere (formidable-pro#6763).
cy.get( '[id^="field_"]' ).filter( 'input, textarea' ).eq( 0 ).should( 'have.focus' );
cy.get( '[id^="field_"]' ).filter( 'input, textarea' ).eq( 1 ).clear();
cy.get( '[id^="field_"]' ).filter( 'input, textarea' ).eq( 2 ).clear();
cy.get( "button[type='submit']" ).should( 'contain', 'Submit' ).click();
Expand Down
Loading