Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5750ca9

Browse files
authored
Merge pull request gridstack#2210 from adumesny/master
restored grid option.handle check
2 parents c6e00a0 + 0d4f188 commit 5750ca9

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

doc/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ Change log
8484

8585
## 7.2.3-dev (TBD)
8686
* fix [#2206](https://github.com/gridstack/gridstack.js/issues/2206) `load()` with collision fix
87+
* fix [#2210](https://github.com/gridstack/gridstack.js/pull/2210) restored checking for grid option.handle draggable area
8788

8889
## 7.2.3 (2023-02-02)
8990
* fix `addWidget()` to handle passing just {el} which was needed for Angular HMTL template demo

src/dd-draggable.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
6565
this.el = el;
6666
this.option = option;
6767
// get the element that is actually supposed to be dragged by
68-
let className = option.handle.substring(1);
69-
this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;
68+
let handleName = option.handle.substring(1);
69+
this.dragEl = el.classList.contains(handleName) ? el : el.querySelector(option.handle) || el;
7070
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
7171
this._mouseDown = this._mouseDown.bind(this);
7272
this._mouseMove = this._mouseMove.bind(this);
@@ -138,12 +138,11 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
138138

139139
// make sure we are clicking on a drag handle or child of it...
140140
// Note: we don't need to check that's handle is an immediate child, as mouseHandled will prevent parents from also handling it (lowest wins)
141-
//
142-
// REMOVE: why would we get the event if it wasn't for us or child ?
143-
// let className = this.option.handle.substring(1);
144-
// let el = e.target as HTMLElement;
145-
// while (el && !el.classList.contains(className)) { el = el.parentElement; }
146-
// if (!el) return;
141+
let className = this.option.handle.substring(1);
142+
let el = e.target as HTMLElement;
143+
while (el && !el.classList.contains(className)) { el = el.parentElement; }
144+
if (!el) return;
145+
147146
this.mouseDownEvent = e;
148147
delete this.dragging;
149148
delete DDManager.dragElement;

0 commit comments

Comments
 (0)