Skip to content

Commit

Permalink
restored grid option.handle check
Browse files Browse the repository at this point in the history
* had incorrectly commented out code that only allowed dragging by the specified handle in gridstack#2063
  • Loading branch information
adumesny committed Feb 11, 2023
1 parent c6e00a0 commit 0d4f188
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions doc/CHANGES.md
Expand Up @@ -84,6 +84,7 @@ Change log

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

## 7.2.3 (2023-02-02)
* fix `addWidget()` to handle passing just {el} which was needed for Angular HMTL template demo
Expand Down
15 changes: 7 additions & 8 deletions src/dd-draggable.ts
Expand Up @@ -65,8 +65,8 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
this.el = el;
this.option = option;
// get the element that is actually supposed to be dragged by
let className = option.handle.substring(1);
this.dragEl = el.classList.contains(className) ? el : el.querySelector(option.handle) || el;
let handleName = option.handle.substring(1);
this.dragEl = el.classList.contains(handleName) ? el : el.querySelector(option.handle) || el;
// create var event binding so we can easily remove and still look like TS methods (unlike anonymous functions)
this._mouseDown = this._mouseDown.bind(this);
this._mouseMove = this._mouseMove.bind(this);
Expand Down Expand Up @@ -138,12 +138,11 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt

// make sure we are clicking on a drag handle or child of it...
// 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)
//
// REMOVE: why would we get the event if it wasn't for us or child ?
// let className = this.option.handle.substring(1);
// let el = e.target as HTMLElement;
// while (el && !el.classList.contains(className)) { el = el.parentElement; }
// if (!el) return;
let className = this.option.handle.substring(1);
let el = e.target as HTMLElement;
while (el && !el.classList.contains(className)) { el = el.parentElement; }
if (!el) return;

this.mouseDownEvent = e;
delete this.dragging;
delete DDManager.dragElement;
Expand Down

0 comments on commit 0d4f188

Please sign in to comment.