Skip to content

Commit 95fc764

Browse files
committed
disable pointer events on iframes
* while dragging/resizing so fast mouse moves aren't swallowed by the iframe's own document * fix #934
1 parent 4db4868 commit 95fc764

4 files changed

Lines changed: 16 additions & 0 deletions

File tree

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ Change log
149149
## 13.2.0-dev (TBD)
150150
* feat: [#2781](https://github.com/gridstack/gridstack.js/issues/3177) [#2781](https://github.com/gridstack/gridstack.js/issues/3177) mobile: pause to drag/reszie vs scroll behavior
151151
* fix: [#3374](https://github.com/gridstack/gridstack.js/issues/3374) use `moveBefore()` (when supported) instead of `appendChild()` in `_sortDom()` so reordering doesn't reload iframes / lose element state
152+
* fix: [#934](https://github.com/gridstack/gridstack.js/issues/934) disable pointer events on iframes while dragging/resizing so fast mouse moves aren't swallowed by the iframe's own document
152153

153154
## 13.2.0 (2026-08-19)
154155
* feat: [#701](https://github.com/gridstack/gridstack.js/issues/701) removed printMode as we support much better printing now that doesn't compromise.

src/dd-draggable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
247247
* don't start unless we've moved at least 3 pixels
248248
*/
249249
this.dragging = true;
250+
Utils.pauseIframePointerEvents(true);
250251
this.el.classList.remove('ui-draggable-armed');
251252
DDManager.dragElement = this;
252253
// if we're dragging an actual grid item, set the current drop as the grid (to detect enter/leave)
@@ -287,6 +288,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
287288
}
288289
if (this.dragging) {
289290
delete this.dragging;
291+
Utils.pauseIframePointerEvents(false);
290292
delete (this.el.gridstackNode as GridStackNodeRotate)?._origRotate;
291293
document.removeEventListener('keydown', this._keyEvent);
292294

src/dd-resizable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
177177
this.scrollY = this.scrollEl.scrollTop;
178178
this.scrolled = 0;
179179
this.startEvent = event;
180+
Utils.pauseIframePointerEvents(true);
180181
this._setupHelper();
181182
this._applyChange();
182183
const ev = Utils.initEvent<MouseEvent>(event, { type: 'resizestart', target: this.el });
@@ -207,6 +208,7 @@ export class DDResizable extends DDBaseImplement implements HTMLElementExtendOpt
207208
/** @internal */
208209
protected _resizeStop(event: MouseEvent): DDResizable {
209210
const ev = Utils.initEvent<MouseEvent>(event, { type: 'resizestop', target: this.el });
211+
Utils.pauseIframePointerEvents(false);
210212
// Remove style attr now, so the stop handler can rebuild style attrs
211213
this._cleanHelper();
212214
if (this.option.stop) {

src/utils.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,17 @@ export class Utils {
559559
}
560560
}
561561

562+
/**
563+
* disable/re-enable pointer events on all iframes on the page while dragging/resizing, otherwise
564+
* fast mouse moves over an iframe get swallowed by its own document instead of reaching ours,
565+
* which stalls the drag/resize. See https://github.com/gridstack/gridstack.js/issues/934
566+
*/
567+
static pauseIframePointerEvents(pause: boolean): void {
568+
document.querySelectorAll('iframe').forEach(iframe => {
569+
(iframe as HTMLIFrameElement).style.pointerEvents = pause ? 'none' : '';
570+
});
571+
}
572+
562573
/** single level clone, returning a new object with same top fields. This will share sub objects and arrays */
563574
static clone<T>(obj: T): T {
564575
if (obj === null || obj === undefined || typeof(obj) !== 'object') {

0 commit comments

Comments
 (0)