Skip to content

Commit

Permalink
fix: make css selectors more specific when identifying form control w…
Browse files Browse the repository at this point in the history
…rap and input-controls
  • Loading branch information
lucasnetau committed Jul 1, 2024
1 parent d9695cc commit 44c94f6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/js/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ function FormBuilder(opts, element, $) {
$(element).replaceWith($editorWrap)
}

$(d.controls).on('click', 'li', ({ target }) => {
$(d.controls).on('click', 'li.input-control, li.input-set-control', ({ target }) => {
//Remove initial placeholder if simply clicking to add field into blank stage
if (h.stageIsEmpty()) {
$stage.find(tmpRowPlaceholderClassSelector).eq(0).remove()
Expand Down
6 changes: 5 additions & 1 deletion src/js/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class Helpers {
if (ui.sender) {
$(ui.sender).sortable('cancel')
}
this.from.sortable('cancel')
this.from.closest('.frmb-control').sortable('cancel')
}
_this.save()
_this.doCancel = false
Expand All @@ -90,10 +90,14 @@ export default class Helpers {
//Find the index within the stage even if the placeholder is not a direct descendant
_this.stopIndex = ui.placeholder.closest('ul.stage-wrap > *').index() - 1

//Cancel the sort if sortableControls is disabled and the drop target is the control panel
if (!opts.sortableControls && ui.item.parent().hasClass('frmb-control')) {
cancelArray.push(true)
}

//Cancel the drop if an element that is not a li.input-control is dropped onto the stage (eg. an input-group container)
cancelArray.push(ui.item.is(':not(li.input-control,li.input-set-control)') && !ui.item.parent().hasClass('frmb-control') )

if (opts.prepend) {
cancelArray.push(_this.stopIndex === 0)
}
Expand Down

0 comments on commit 44c94f6

Please sign in to comment.