Skip to content

Commit 14c9934

Browse files
committed
Fix #105 Drag-and-drop not working in Chrome
1 parent a15746a commit 14c9934

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"blanket": "^1.1.0",
2222
"qunit": "^1.17.0",
2323
"bootstrap-select": "^1.6.0",
24-
"bootbox": "^3.3.0",
24+
"bootbox": "^4.3.0",
2525
"awesome-bootstrap-checkbox": "^0.3.0"
2626
},
2727
"keywords": [

src/plugins/sortable/plugin.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ QueryBuilder.define('sortable', function(options) {
3333

3434
src = Model(e.target);
3535

36-
var ph = $('<div class="rule-placeholder">&nbsp;</div>');
37-
ph.css('min-height', src.$el.height());
36+
// Chrome glitchs
37+
// - helper invisible if hidden immediately
38+
// - "dragend" is called immediately if we modify the DOM directly
39+
setTimeout(function() {
40+
var ph = $('<div class="rule-placeholder">&nbsp;</div>');
41+
ph.css('min-height', src.$el.height());
3842

39-
placeholder = src.parent.addRule(ph, src.getPos());
43+
placeholder = src.parent.addRule(ph, src.getPos());
4044

41-
// Chrome glitch (helper invisible if hidden immediately)
42-
setTimeout(function() {
4345
src.$el.hide();
4446
}, 0);
4547
});
@@ -49,7 +51,9 @@ QueryBuilder.define('sortable', function(options) {
4951
e.preventDefault();
5052
e.stopPropagation();
5153

52-
moveSortableToTarget(placeholder, $(e.target));
54+
if (placeholder) {
55+
moveSortableToTarget(placeholder, $(e.target));
56+
}
5357
});
5458

5559
// dragover: prevent glitches

tests/data.module.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ $(function(){
5858
/operator_not_multiple/
5959
);
6060

61-
assert.validationError($b,
62-
{ id: 'select' },
63-
/select_empty/
64-
);
65-
6661
assert.validationError($b,
6762
{ id: 'select_mult' },
6863
/select_empty/

0 commit comments

Comments
 (0)