Skip to content

Commit a8b6b7c

Browse files
committed
added .grid-stack-dragging to grid when child is being dragged
* fix #3047 * added `.grid-stack-dragging` to grid when child is being dragged so we can set cursor:grabbing, updated demo.
1 parent cb1221e commit a8b6b7c

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

demo/demo.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,16 @@ h1 {
5656

5757
.card-header {
5858
margin: 0;
59-
cursor: move;
59+
cursor: grab;
6060
min-height: 25px;
6161
background-color: #16af91;
6262
}
6363
.card-header:hover {
6464
background-color: #149b80;
6565
}
66+
.grid-stack-dragging {
67+
cursor: grabbing;
68+
}
6669

6770
.ui-draggable-disabled.ui-resizable-disabled > .grid-stack-item-content {
6871
background-color: #777;

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ Change log
134134
## 12.2.2-dev (TBD)
135135
* fix: [#3099](https://github.com/gridstack/gridstack.js/issues/3099) scroll take into account ScrollContainer position
136136
* fix: [#3102](https://github.com/gridstack/gridstack.js/pull/3102) React demo now support multiple grids
137+
* fix: [#3047](https://github.com/gridstack/gridstack.js/issues/3047) added `.grid-stack-dragging` to grid when child is being dragged so we can set cursor:grabbing, updated demo.
137138

138139
## 12.2.2 (2025-07-06)
139140
* fix: [#3070](https://github.com/gridstack/gridstack.js/pull/3070) incorrect property name 'sizeToContent' when cleaning up invalid attributes

src/dd-draggable.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
309309
/** @internal set the fix position of the dragged item */
310310
protected _setupHelperStyle(e: DragEvent): DDDraggable {
311311
this.helper.classList.add('ui-draggable-dragging');
312+
this.el.gridstackNode?.grid?.el.classList.add('grid-stack-dragging');
312313
// TODO: set all at once with style.cssText += ... ? https://stackoverflow.com/questions/3968593
313314
const style = this.helper.style;
314315
style.pointerEvents = 'none'; // needed for over items to get enter/leave
@@ -330,6 +331,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
330331
/** @internal restore back the original style before dragging */
331332
protected _removeHelperStyle(): DDDraggable {
332333
this.helper.classList.remove('ui-draggable-dragging');
334+
this.el.gridstackNode?.grid?.el.classList.remove('grid-stack-dragging');
333335
const node = (this.helper as GridItemHTMLElement)?.gridstackNode;
334336
// don't bother restoring styles if we're gonna remove anyway...
335337
if (!node?._isAboutToRemove && this.dragElementOriginStyle) {

0 commit comments

Comments
 (0)