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.

24 changes: 24 additions & 0 deletions js/src/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,7 @@ function frmAdminBuildJS() {
insertNewFieldByDragging( draggable.id );
} else {
moveFieldThatAlreadyExists( draggable, placeholder );
maybeMakeFieldGroupDraggableAfterDragging( placeholder.parentElement );
}

const previousSectionId = previousSection ? parseInt( previousSection.closest( '.edit_field_type_divider' ).getAttribute( 'data-fid' ) ) : 0;
Expand All @@ -1014,6 +1015,29 @@ function frmAdminBuildJS() {
debouncedSyncAfterDragAndDrop();
}

/**
* When a field is moved into a field group, make sure the field group is draggable.
*
* @since x.x
*
* @param {HTMLElement} placeholderParent
* @return {void}
*/
function maybeMakeFieldGroupDraggableAfterDragging( placeholderParent ) {
const isDroppingIntoFieldGroup = placeholderParent.nodeName === 'UL' &&
! placeholderParent.classList.contains( 'start_divider' ) &&
'frm-show-fields' !== placeholderParent.id;

if ( ! isDroppingIntoFieldGroup ) {
return;
}

const fieldGroupLi = placeholderParent.closest( 'li' );
if ( fieldGroupLi && ! fieldGroupLi.classList.contains( 'ui-draggable' ) ) {
makeDraggable( fieldGroupLi, '.frm-move' );
}
}

/**
* If a page if collapsed, expand it before dragging since only the page break will move.
*
Expand Down
Loading