Skip to content

Commit 2fab00c

Browse files
authored
Fix drag-n-drop with FluentUI (#416)
* Fix drag-n-drop for FluentUI
1 parent b62bc03 commit 2fab00c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changelog
22
- 4.0.4
3+
- Fixed issue #349 with drag-n-drop and office-ui-fabric-react
34
- Fixed issue #413 with func arg with 1 value source which is not value
45
- 4.0.3
56
- Fixed issue #386 with import select field from JsonLogic (reason: bug with func/field widget in getWidgetForFieldOp)

modules/components/containers/SortableContainer.jsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ export default (Builder, CanMoveFn = null) => {
139139
}
140140
}
141141

142+
_getEventTarget = (e, dragStart) => {
143+
return e && e.__mocked_window || document.body || window;
144+
}
145+
142146
onDragStart = (id, dom, e) => {
143147
let treeEl = dom.closest(".query-builder");
144148
document.body.classList.add("qb-dragging");
@@ -183,7 +187,8 @@ export default (Builder, CanMoveFn = null) => {
183187
clientY: e.clientY,
184188
};
185189

186-
const target = e.__mocked_window || window;
190+
const target = this._getEventTarget(e, dragStart);
191+
this.eventTarget = target;
187192
target.addEventListener("mousemove", this.onDrag);
188193
target.addEventListener("mouseup", this.onDragEnd);
189194

@@ -263,10 +268,11 @@ export default (Builder, CanMoveFn = null) => {
263268
document.body.classList.remove("qb-dragging");
264269
this._cacheEls = {};
265270

266-
window.removeEventListener("mousemove", this.onDrag);
267-
window.removeEventListener("mouseup", this.onDragEnd);
271+
const target = this.eventTarget || this._getEventTarget();
272+
target.removeEventListener("mousemove", this.onDrag);
273+
target.removeEventListener("mouseup", this.onDragEnd);
268274
}
269-
275+
270276

271277
handleDrag (dragInfo, e, canMoveFn) {
272278
const canMoveBeforeAfterGroup = true;

0 commit comments

Comments
 (0)