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

Sortable plugin can break the query builder #627

Closed
chriskr opened this issue Jan 12, 2018 · 1 comment
Closed

Sortable plugin can break the query builder #627

chriskr opened this issue Jan 12, 2018 · 1 comment
Labels
bug Identified bug which needs a fix
Milestone

Comments

@chriskr
Copy link

chriskr commented Jan 12, 2018

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.

@chriskr
Copy link
Author

chriskr commented Jan 13, 2018

The issue interact. Drag and drop works fine on http://querybuilder.js.org/demo.html#plugins. This uses interact.js v1.2.6 while the local dev version installs the newest interact.js v1.3.3. The difference is the order of event dispatch, v1.2.6 fires the drag end event after the drop event while v1.3.3 fires the end event before the drop. This removes the placeholder in the model before the rule is moved to the target position, in the worst case causing the rule to disappear and breaking the query builder.

Relevant code in the plugin

onend: function() {
// remove ghost
ghost.remove();
ghost = undefined;
// remove placeholder
placeholder.drop();
placeholder = undefined;

and
ondrop: function(event) {
moveSortableToTarget(src, $(event.target), self);
}

@mistic100 mistic100 added this to the 2.4.6 milestone Feb 26, 2018
@mistic100 mistic100 added the bug Identified bug which needs a fix label Feb 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identified bug which needs a fix
Projects
None yet
Development

No branches or pull requests

2 participants