Skip to content

Commit

Permalink
fix: Only setup sortable row wrapper and invisible row placeholders w…
Browse files Browse the repository at this point in the history
…hen adding a row to the stage
  • Loading branch information
lucasnetau committed Nov 28, 2023
1 parent 28e1236 commit 9e7cf6c
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/js/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ function FormBuilder(opts, element, $) {
if (enhancedBootstrapEnabled()) {
const targetRow = `div.row-${columnData.rowUniqueId}`

let newRowCreated = false
//Check if an overall row already exists for the field, else create one
if ($stage.children(targetRow).length) {
rowWrapperNode = $stage.children(targetRow)
Expand All @@ -1141,6 +1142,7 @@ function FormBuilder(opts, element, $) {
id: `${field.id}-row`,
className: `row row-${columnData.rowUniqueId} ${rowWrapperClass}`,
})
newRowCreated = true
}

//Turn the placeholder into the new row. Copy some attributes over
Expand All @@ -1159,7 +1161,7 @@ function FormBuilder(opts, element, $) {
})

if (insertingNewControl && insertTargetIsColumn) {
if ($targetInsertWrapper.attr('prepend') == 'true') {
if ($targetInsertWrapper.attr('prepend') === 'true') {
$(colWrapperNode).prependTo(rowWrapperNode)
} else {
$(colWrapperNode).insertAfter(`#${$targetInsertWrapper.attr('appendAfter')}`)
Expand All @@ -1178,9 +1180,10 @@ function FormBuilder(opts, element, $) {

$li.appendTo(colWrapperNode)

setupSortableRowWrapper(rowWrapperNode)

SetupInvisibleRowPlaceholders(rowWrapperNode)
if (newRowCreated) {
setupSortableRowWrapper(rowWrapperNode)
SetupInvisibleRowPlaceholders(rowWrapperNode)
}

//Record the fact that this field did not originally have column information stored.
//If no other fields were added to the same row and the user did not do anything with this information, then remove it when exporting the config
Expand Down

0 comments on commit 9e7cf6c

Please sign in to comment.