Skip to content

Sortable plugin can break the query builder #627

Closed
@chriskr

Description

@chriskr

Issue is reproducible with examples/index.html of the repo. Create two rules, drag the first one and drop it when it overlaps the placeholder and the other rule to more or less the same degree. The drag target disappears and adding new rules no longer works.

The issue seems to be here

'move': function(e, node, group, index) {
node.$el.detach();
if (index === 0) {
node.$el.prependTo(group.$el.find('>' + QueryBuilder.selectors.rules_list));
}
else {
node.$el.insertAfter(group.rules[index - 1].$el);
}
self.refreshGroupsConditions();
},
. If group.rules[index - 1].$el is the node itself then insertAfter does obviously nothing. Suggested fix would be to add

if (index > 0 && node === group.rules[index - 1]) {
    return;
}

If that is ok I can make an according fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIdentified bug which needs a fix

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions