Skip to content

Commit 63754ba

Browse files
committed
allow button as handle dragging
* fix #2677 * allow event target to be draggable even if in the blocked list if that is the specified handle.
1 parent bb5e0d6 commit 63754ba

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Change log
112112
## 10.1.2-dev (TBD)
113113
* fix: [#2672](https://github.com/gridstack/gridstack.js/pull/2672) dropping into full grid JS error
114114
* fix: [#2676](https://github.com/gridstack/gridstack.js/issues/2676) handle minW resizing when column count is less
115+
* fix: [#2677](https://github.com/gridstack/gridstack.js/issues/2677) allow button as handle dragging
115116

116117
## 10.1.2 (2024-03-30)
117118
* fix: [#2628](https://github.com/gridstack/gridstack.js/issues/2628) `removeAll()` does not trigger Angular's ngOnDestroy

spec/e2e/html/2677_drag_button.html

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<title>drag button demo</title>
8+
9+
<link rel="stylesheet" href="../../../demo/demo.css" />
10+
<script src="../../../dist/gridstack-all.js"></script>
11+
<style>
12+
.handle { cursor: move }
13+
</style>
14+
</head>
15+
<body>
16+
<div class="grid-stack"></div>
17+
<script type="text/javascript">
18+
let items = [
19+
{x: 0, y: 0, content: '<button class="handle">Handle</button>'},
20+
{x: 1, y: 0, w: 3, content: '<span class="handle">Handle</span>'},
21+
];
22+
let grid = GridStack.init({handle: '.handle', cellHeight: 70}).load(items);
23+
</script>
24+
</body>
25+
</html>

src/dd-draggable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
136136
if (e.button !== 0) return true; // only left click
137137

138138
// make sure we are not clicking on known object that handles mouseDown, or ones supplied by the user
139-
if ((e.target as HTMLElement).closest(skipMouseDown)) return true;
139+
if (e.target !== this.dragEl && (e.target as HTMLElement).closest(skipMouseDown)) return true;
140140
if (this.option.cancel) {
141141
if ((e.target as HTMLElement).closest(this.option.cancel)) return true;
142142
}

0 commit comments

Comments
 (0)