@@ -135,6 +135,7 @@ function FormBuilder(opts, element, $) {
135135 cursor : 'move' ,
136136 scroll : false ,
137137 placeholder : 'hoverDropStyleInverse ui-state-highlight' ,
138+ tolerance : 'pointer' ,
138139 start : ( evt , ui ) => h . startMoving . call ( h , evt , ui ) ,
139140 stop : ( evt , ui ) => {
140141 h . stopMoving . call ( h , evt , ui )
@@ -1138,6 +1139,7 @@ function FormBuilder(opts, element, $) {
11381139 if ( enhancedBootstrapEnabled ( ) ) {
11391140 const targetRow = `div.row-${ columnData . rowUniqueId } `
11401141
1142+ let newRowCreated = false
11411143 //Check if an overall row already exists for the field, else create one
11421144 if ( $stage . children ( targetRow ) . length ) {
11431145 rowWrapperNode = $stage . children ( targetRow )
@@ -1146,6 +1148,7 @@ function FormBuilder(opts, element, $) {
11461148 id : `${ field . id } -row` ,
11471149 className : `row row-${ columnData . rowUniqueId } ${ rowWrapperClass } ` ,
11481150 } )
1151+ newRowCreated = true
11491152 }
11501153
11511154 //Turn the placeholder into the new row. Copy some attributes over
@@ -1164,7 +1167,7 @@ function FormBuilder(opts, element, $) {
11641167 } )
11651168
11661169 if ( insertingNewControl && insertTargetIsColumn ) {
1167- if ( $targetInsertWrapper . attr ( 'prepend' ) == 'true' ) {
1170+ if ( $targetInsertWrapper . attr ( 'prepend' ) === 'true' ) {
11681171 $ ( colWrapperNode ) . prependTo ( rowWrapperNode )
11691172 } else {
11701173 $ ( colWrapperNode ) . insertAfter ( `#${ $targetInsertWrapper . attr ( 'appendAfter' ) } ` )
@@ -1177,15 +1180,29 @@ function FormBuilder(opts, element, $) {
11771180 }
11781181
11791182 //If inserting, use the existing index, do not always append to end
1180- if ( ! insertingNewControl ) {
1183+ if ( ! insertingNewControl && newRowCreated ) {
11811184 $li . after ( rowWrapperNode )
11821185 }
11831186
11841187 $li . appendTo ( colWrapperNode )
11851188
1186- setupSortableRowWrapper ( rowWrapperNode )
1189+ if ( newRowCreated ) {
1190+ setupSortableRowWrapper ( rowWrapperNode )
1191+ hideInvisibleRowPlaceholders ( )
1192+ SetupInvisibleRowPlaceholders ( rowWrapperNode )
1193+ if ( opts . enableColumnInsertMenu ) {
1194+ $ ( rowWrapperNode ) . off ( 'mouseenter' )
1195+ $ ( rowWrapperNode ) . on ( 'mouseenter' , function ( e ) {
1196+ setupColumnInserts ( $ ( e . currentTarget ) )
1197+ } )
11871198
1188- SetupInvisibleRowPlaceholders ( rowWrapperNode )
1199+ $ ( rowWrapperNode ) . off ( 'mouseleave' )
1200+ $ ( rowWrapperNode ) . on ( 'mouseleave' , function ( e ) {
1201+ hideColumnInsertButtons ( $ ( e . currentTarget ) )
1202+ } )
1203+ }
1204+ }
1205+ setupColumnInserts ( rowWrapperNode , true )
11891206
11901207 //Record the fact that this field did not originally have column information stored.
11911208 //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
@@ -1258,7 +1275,7 @@ function FormBuilder(opts, element, $) {
12581275
12591276 wrapperClone . insertAfter ( $ ( rowWrapperNode ) )
12601277 setupSortableRowWrapper ( wrapperClone )
1261- $stage . find ( rowWrapperClassSelector + ':last-child ' ) . removeClass ( invisibleRowPlaceholderClass )
1278+ $stage . find ( rowWrapperClassSelector + ':last-of-type ' ) . removeClass ( invisibleRowPlaceholderClass )
12621279 }
12631280
12641281 function ResetAllInvisibleRowPlaceholders ( ) {
@@ -1268,7 +1285,7 @@ function FormBuilder(opts, element, $) {
12681285 SetupInvisibleRowPlaceholders ( $ ( elem ) )
12691286 } )
12701287
1271- $stage . find ( rowWrapperClassSelector + ':last-child ' ) . removeClass ( invisibleRowPlaceholderClass )
1288+ $stage . find ( rowWrapperClassSelector + ':last-of-type ' ) . removeClass ( invisibleRowPlaceholderClass )
12721289 }
12731290
12741291 function setupSortableRowWrapper ( rowWrapperNode ) {
@@ -1402,19 +1419,6 @@ function FormBuilder(opts, element, $) {
14021419 if ( rowId !== '0' ) {
14031420 $ ( rowWrapperNode ) . attr ( 'data-row-id' , rowId )
14041421 }
1405-
1406- setupColumnInserts ( rowWrapperNode , true )
1407- if ( opts . enableColumnInsertMenu ) {
1408- $ ( rowWrapperNode ) . off ( 'mouseenter' )
1409- $ ( rowWrapperNode ) . on ( 'mouseenter' , function ( e ) {
1410- setupColumnInserts ( $ ( e . currentTarget ) )
1411- } )
1412-
1413- $ ( rowWrapperNode ) . off ( 'mouseleave' )
1414- $ ( rowWrapperNode ) . on ( 'mouseleave' , function ( e ) {
1415- hideColumnInsertButtons ( $ ( e . currentTarget ) )
1416- } )
1417- }
14181422 }
14191423
14201424 function CheckTinyMCETransition ( fieldListItem ) {
0 commit comments