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

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/formidable_styles.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions js/onboarding-wizard.js.map

Large diffs are not rendered by default.

22 changes: 18 additions & 4 deletions js/src/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2385,6 +2385,11 @@ window.frmAdminBuildJS = function() {
fieldOrder = this.getAttribute( 'frm-field-order' );
}

const getSectionField = $fieldObject => {
const liElement = $fieldObject.get( 0 ).querySelector( 'ul li[data-ftype="divider"]' );
return liElement ? jQuery( liElement ) : $fieldObject;
};

jQuery.ajax( {
type: 'POST',
url: ajaxurl,
Expand All @@ -2404,7 +2409,10 @@ window.frmAdminBuildJS = function() {
newRow = document.getElementById( newRowId );
if ( null !== newRow ) {
replaceWith = msgAsjQueryObject( msg );
jQuery( newRow ).append( replaceWith );
const newField = getSectionField( replaceWith );

jQuery( newRow ).append( newField );

makeDraggable( replaceWith.get( 0 ), '.frm-move' );
if ( null !== fieldOrder ) {
newRow.lastElementChild.setAttribute( 'frm-field-order', fieldOrder );
Expand All @@ -2424,12 +2432,18 @@ window.frmAdminBuildJS = function() {

if ( $field.siblings( 'li.form-field' ).length ) {
replaceWith = msgAsjQueryObject( msg );
$field.after( replaceWith );
const newField = getSectionField( replaceWith );
$field.after( newField );
syncLayoutClasses( $field );
makeDraggable( replaceWith.get( 0 ), '.frm-move' );

const layoutClass = getLayoutClassName( $field.get( 0 ).classList );
if ( ! newField.get( 0 ).classList.contains( layoutClass ) ) {
newField.get( 0 ).classList.add( layoutClass );
}
} else {
replaceWith = wrapFieldLi( msg );
$field.parent().parent().after( replaceWith );
$field.parent().parent().after( getSectionField( replaceWith ) );
makeDroppable( replaceWith.get( 0 ).querySelector( 'ul.frm_sorting' ) );
makeDraggable( replaceWith.get( 0 ).querySelector( 'li.form-field' ), '.frm-move' );
}
Expand Down Expand Up @@ -6888,7 +6902,7 @@ window.frmAdminBuildJS = function() {
replaceWith = replaceWith.trim();
}

field.className = field.className.replace( replace, replaceWith );
field.className = field.className.replace( /\s+/g, ' ' ).replace( replace, replaceWith );
}

function maybeShowInlineModal( e ) {
Expand Down