From 48a547479a9f48a6cfb2a302837740f03b0bbe88 Mon Sep 17 00:00:00 2001 From: Alain Dumesny Date: Sat, 20 Jul 2024 18:56:42 -0700 Subject: [PATCH] nested grid drag fix * fix #2740 * make sure we don't look for all draggable items when we're a nested grid, only first (grid-content) --- doc/CHANGES.md | 3 ++- src/dd-draggable.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 029f7d448..04e7cb849 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -115,7 +115,8 @@ Change log ## 10.3.0-dev (TBD) * fix: [#2734](https://github.com/gridstack/gridstack.js/bug/2734) rotate() JS error -* fix: [#2739](https://github.com/gridstack/gridstack.js/pull/2739) resizeToContent JS error with nested grid +* fix: [#2741](https://github.com/gridstack/gridstack.js/pull/2741) resizeToContent JS error with nested grid +* fix: [#2740](https://github.com/gridstack/gridstack.js/bug/2740) nested grid drag fix ## 10.3.0 (2024-06-26) * fix: [#2720](https://github.com/gridstack/gridstack.js/pull/2720) load() now creates widgets in order (used to be reverse due to old collision code) diff --git a/src/dd-draggable.ts b/src/dd-draggable.ts index 0ef36ed16..ce3f41229 100644 --- a/src/dd-draggable.ts +++ b/src/dd-draggable.ts @@ -79,8 +79,9 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt super(); // get the element that is actually supposed to be dragged by - let handleName = option.handle.substring(1); - this.dragEls = el.classList.contains(handleName) ? [el] : Array.from(el.querySelectorAll(option.handle)); + const handleName = option.handle.substring(1); + const n = el.gridstackNode; + this.dragEls = el.classList.contains(handleName) ? [el] : (n?.subGrid ? [el.querySelector(option.handle) || el] : Array.from(el.querySelectorAll(option.handle))); if (this.dragEls.length === 0) { this.dragEls = [el]; }