Skip to content
Merged
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
2 changes: 1 addition & 1 deletion js/formidable_admin.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions js/src/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2337,7 +2337,6 @@ window.frmAdminBuildJS = function() {
}
}
$placeholder.replaceWith( replaceWith );
updateFieldOrder();
afterAddField( msg, false );
if ( $siblings.length ) {
syncLayoutClasses( $siblings.first() );
Expand Down Expand Up @@ -3154,7 +3153,6 @@ window.frmAdminBuildJS = function() {
resolve( msg );

setTimeout( () => {
updateFieldOrder();
afterAddField( msg, true );

const fieldId = checkMsgForFieldId( msg );
Expand Down Expand Up @@ -3288,7 +3286,6 @@ window.frmAdminBuildJS = function() {
makeDraggable( replaceWith.get( 0 ).querySelector( 'li.form-field' ), '.frm-move' );
}

updateFieldOrder();
afterAddField( msg, false );
maybeDuplicateUnsavedSettings( fieldId, msg );
toggleOneSectionHolder( replaceWith.find( '.start_divider' ) );
Expand Down Expand Up @@ -3660,20 +3657,22 @@ window.frmAdminBuildJS = function() {
}
}

if ( msg.includes( 'frm-collapse-page' ) ) {
renumberPageBreaks();
}

addClass( field, 'frm-newly-added' );
setTimeout( function() {
field.classList.remove( 'frm-newly-added' );
}, 1000 );

// The server moves the submit row below the new field in the database, using the highest saved order.
// Copy those orders so the inputs match the database, then renumber from the builder.
// The saved orders can be lower than the builder positions, and the submit row would end up above other fields.
const lastRowOrderInput = field.querySelector( '#frm-last-row-fields-order' );
if ( lastRowOrderInput ) {
updateLastRowFieldsOrder( JSON.parse( lastRowOrderInput.value ) );
}

// This also renumbers page breaks.
updateFieldOrder();

if ( addFocus ) {
const bounding = field.getBoundingClientRect();
const container = document.getElementById( 'post-body-content' );
Expand Down
Loading