Skip to content

Commit 246fae5

Browse files
authored
Merge pull request #3262 from adumesny/master
DDDraggable fix to querySelectorAll(handle) for nested grid
2 parents c246b71 + 692bbf1 commit 246fae5

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

angular/doc/api/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GridStack Angular Library v12.5.0
1+
# GridStack Angular Library v12.5.0-dev
22

33
## Modules
44

doc/API.md

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# gridstack v12.5.0
1+
# gridstack v12.5.0-dev
22

33
## Classes
44

@@ -1775,7 +1775,7 @@ is dynamically create and needs to be set later.
17751775
protected triggerEvent(event, target): void;
17761776
```
17771777

1778-
Defined in: [gridstack.ts:2974](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L2974)
1778+
Defined in: [gridstack.ts:2976](https://github.com/adumesny/gridstack.js/blob/master/src/gridstack.ts#L2976)
17791779

17801780
call given event callback on our main top-most grid (if we're nested)
17811781

@@ -4003,7 +4003,7 @@ Defined in: [dd-draggable.ts:69](https://github.com/adumesny/gridstack.js/blob/m
40034003
destroy(): void;
40044004
```
40054005

4006-
Defined in: [dd-draggable.ts:122](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L122)
4006+
Defined in: [dd-draggable.ts:131](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L131)
40074007

40084008
Destroy this drag & drop implementation and clean up resources.
40094009
Removes all event handlers and clears internal state.
@@ -4022,7 +4022,7 @@ Removes all event handlers and clears internal state.
40224022
disable(forDestroy): void;
40234023
```
40244024

4025-
Defined in: [dd-draggable.ts:109](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L109)
4025+
Defined in: [dd-draggable.ts:118](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L118)
40264026

40274027
Disable this drag & drop implementation.
40284028
Subclasses should override to perform additional cleanup.
@@ -4047,7 +4047,7 @@ Subclasses should override to perform additional cleanup.
40474047
enable(): void;
40484048
```
40494049

4050-
Defined in: [dd-draggable.ts:95](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L95)
4050+
Defined in: [dd-draggable.ts:104](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L104)
40514051

40524052
Enable this drag & drop implementation.
40534053
Subclasses should override to perform additional setup.
@@ -4060,13 +4060,27 @@ Subclasses should override to perform additional setup.
40604060

40614061
[`DDBaseImplement`](#ddbaseimplement).[`enable`](#enable)
40624062

4063+
##### getAllHandles()
4064+
4065+
```ts
4066+
protected getAllHandles(): HTMLElement[];
4067+
```
4068+
4069+
Defined in: [dd-draggable.ts:88](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L88)
4070+
4071+
return all handles omitting other nested `.grid-stack-item` children (in case where n.subGrid isn't set for some reason)
4072+
4073+
###### Returns
4074+
4075+
`HTMLElement`[]
4076+
40634077
##### off()
40644078

40654079
```ts
40664080
off(event): void;
40674081
```
40684082

4069-
Defined in: [dd-draggable.ts:91](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L91)
4083+
Defined in: [dd-draggable.ts:100](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L100)
40704084

40714085
Unregister an event callback for the specified event.
40724086

@@ -4090,7 +4104,7 @@ Unregister an event callback for the specified event.
40904104
on(event, callback): void;
40914105
```
40924106

4093-
Defined in: [dd-draggable.ts:87](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L87)
4107+
Defined in: [dd-draggable.ts:96](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L96)
40944108

40954109
Register an event callback for the specified event.
40964110

@@ -4142,7 +4156,7 @@ Result from the callback function, if any
41424156
updateOption(opts): DDDraggable;
41434157
```
41444158

4145-
Defined in: [dd-draggable.ts:133](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L133)
4159+
Defined in: [dd-draggable.ts:142](https://github.com/adumesny/gridstack.js/blob/master/src/dd-draggable.ts#L142)
41464160

41474161
Method to update the options and return the DD implementation
41484162

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Change log
140140
## 12.5.0-dev (TBD)
141141
* feat: [#3250](https://github.com/gridstack/gridstack.js/pull/3250) full RTL support - thank you [Daniel Cohen Gindi](https://github.com/danielgindi)
142142
* fix: [#3261](https://github.com/gridstack/gridstack.js/pull/3261) prepareDragDrop() returns for disable after deletion
143+
* fix: [#3262](https://github.com/gridstack/gridstack.js/pull/3262) DDDraggable fix to querySelectorAll(handle) for nested grid
143144

144145
## 12.5.0 (2026-04-05)
145146
* fix: [#3237](https://github.com/gridstack/gridstack.js/pull/3237) updateOptions() fixes for columnOpts, maxRow. load() not cloning

src/dd-draggable.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
7272
// get the element that is actually supposed to be dragged by
7373
const handleName = option?.handle?.substring(1);
7474
const n = el.gridstackNode;
75-
this.dragEls = !handleName || el.classList.contains(handleName) ? [el] : (n?.subGrid ? [el.querySelector(option.handle) || el] : Array.from(el.querySelectorAll(option.handle)));
75+
this.dragEls = !handleName || el.classList.contains(handleName) ? [el] : (n?.subGrid ? [el.querySelector(option.handle) || el] : this.getAllHandles());
7676
if (this.dragEls.length === 0) {
7777
this.dragEls = [el];
7878
}
@@ -84,6 +84,15 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
8484
this.enable();
8585
}
8686

87+
/** return all handles omitting other nested `.grid-stack-item` children (in case node.subGrid isn't set for some reason) */
88+
protected getAllHandles(): HTMLElement[] {
89+
return Array.from(this.el.querySelectorAll(this.option.handle)).filter((node): node is HTMLElement => {
90+
if (!(node instanceof HTMLElement)) return false;
91+
const owner = node.closest('.grid-stack-item');
92+
return owner === this.el || !owner;
93+
});
94+
}
95+
8796
public on(event: DDDragEvent, callback: (event: DragEvent) => void): void {
8897
super.on(event, callback);
8998
}

0 commit comments

Comments
 (0)