Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable GH-1541 request - Control grouping #1572

Merged
merged 2 commits into from
Jul 4, 2024
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
4 changes: 2 additions & 2 deletions src/js/form-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function FormBuilder(opts, element, $) {
return false
}

if ($(ui.item).closest('.stage-wrap') && $(ui.item).closest(rowWrapperClassSelector).length === 0) {
if ($(ui.item).closest('.stage-wrap').length && $(ui.item).closest(rowWrapperClassSelector).length === 0) {
h.doCancel = true
processControl(ui.item)
} else {
Expand Down 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
Loading